Skip to content

Commit

Permalink
Catch exception if node is in unexpected statement (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmojaki authored Aug 29, 2024
1 parent ea6a695 commit 6428317
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions executing/executing.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,16 +273,15 @@ def executing(cls, frame_or_tb):
node_finder = NodeFinder(frame, stmts, tree, lasti, source)
node = node_finder.result
decorator = node_finder.decorator

if node:
new_stmts = {statement_containing_node(node)}
assert_(new_stmts <= stmts)
stmts = new_stmts
except Exception:
if TESTING:
raise

assert stmts is not None
if node:
new_stmts = {statement_containing_node(node)}
assert_(new_stmts <= stmts)
stmts = new_stmts

executing_cache[key] = args = source, node, stmts, decorator

return Executing(frame, *args)
Expand Down

0 comments on commit 6428317

Please sign in to comment.