You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importastevalasteval.Interpreter().eval("""try: 2 + ""except Exception as err: print(err)""", raise_errors=True)
OUTPUT:
NameError:
try:
2 + ""
except Exception as err:
print(err)
^^^^
NameError: name 'err' is not defined
What's going wrong here:
From the documentation of ast.ExceptHandler: name is a raw string for the name to hold the exception, or None if the clause doesn’t have as
node_assign is called with the hnd.name which is a string.
However, node_assign does not have a case for str so the exception is never assigned to a name in the symbol table.
The text was updated successfully, but these errors were encountered:
This code snippet reproduces the problem:
OUTPUT:
What's going wrong here:
From the documentation of
ast.ExceptHandler
:name
is a raw string for the name to hold the exception, orNone
if the clause doesn’t haveas
In
on_try
, at this lineasteval/asteval/asteval.py
Line 870 in aeea1b7
node_assign
is called with thehnd.name
which is a string.However,
node_assign
does not have a case forstr
so the exception is never assigned to a name in the symbol table.The text was updated successfully, but these errors were encountered: