Wow, drop idiotic `return` inside `finally:`
Can't believe i missed this but any `return` inside a `finally` will suppress the error from the `try:` part... XD Thought i was losing my mind when the ledger was mutated and then an error just after wasn't getting raised.. lul. Never again...pptables
parent
ddb195ed2c
commit
5684120c11
11
piker/pp.py
11
piker/pp.py
|
@ -82,9 +82,9 @@ def open_trade_ledger(
|
|||
ledger = tomli.load(cf)
|
||||
print(f'Ledger load took {time.time() - start}s')
|
||||
cpy = ledger.copy()
|
||||
try:
|
||||
|
||||
yield cpy
|
||||
finally:
|
||||
|
||||
if cpy != ledger:
|
||||
# TODO: show diff output?
|
||||
# https://stackoverflow.com/questions/12956957/print-diff-of-python-dictionaries
|
||||
|
@ -93,7 +93,7 @@ def open_trade_ledger(
|
|||
|
||||
# we write on close the mutated ledger data
|
||||
with open(tradesfile, 'w') as cf:
|
||||
return toml.dump(ledger, cf)
|
||||
toml.dump(ledger, cf)
|
||||
|
||||
|
||||
class Transaction(Struct, frozen=True):
|
||||
|
@ -764,12 +764,7 @@ def open_pps(
|
|||
clears=clears,
|
||||
)
|
||||
|
||||
# orig = pp_objs.copy()
|
||||
try:
|
||||
yield table
|
||||
finally:
|
||||
# breakpoint()
|
||||
# if orig != table.pps:
|
||||
|
||||
if not write_on_exit:
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue