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
REDACT\venv\Scripts\python.exe REDACT\test.py
Traceback (most recent call last):
File "REDACT\venv\Lib\site-packages\asteval\asteval.py", line 293, in run
ret = handler(node)
^^^^^^^^^^^^^
File "REDACT\venv\Lib\site-packages\asteval\asteval.py", line 513, in on_name
return self._getsym(node)
^^^^^^^^^^^^^^^^^^
File "REDACT\venv\Lib\site-packages\asteval\asteval.py", line 505, in _getsym
self.raise_exception(node, exc=NameError, msg=msg)
File "REDACT\venv\Lib\site-packages\asteval\asteval.py", line 242, in raise_exception
raise exc(self.error_msg)
NameError: name 'i_dont_exist' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "REDACT\venv\Lib\site-packages\asteval\asteval.py", line 293, in run
ret = handler(node)
^^^^^^^^^^^^^
File "REDACT\venv\Lib\site-packages\asteval\asteval.py", line 356, in on_expr
return self.run(node.value) # ('value',)
^^^^^^^^^^^^^^^^^^^^
File "REDACT\venv\Lib\site-packages\asteval\asteval.py", line 299, in run
self.raise_exception(node, expr=expr)
File "REDACT\venv\Lib\site-packages\asteval\asteval.py", line 242, in raise_exception
raise exc(self.error_msg)
NameError: name 'i_dont_exist' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "REDACT\venv\Lib\site-packages\asteval\asteval.py", line 293, in run
ret = handler(node)
^^^^^^^^^^^^^
File "REDACT\venv\Lib\site-packages\asteval\asteval.py", line 432, in on_module
out = self.run(tnode)
^^^^^^^^^^^^^^^
File "REDACT\venv\Lib\site-packages\asteval\asteval.py", line 299, in run
self.raise_exception(node, expr=expr)
File "REDACT\venv\Lib\site-packages\asteval\asteval.py", line 242, in raise_exception
raise exc(self.error_msg)
NameError: name 'i_dont_exist' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "REDACT\venv\Lib\site-packages\asteval\asteval.py", line 337, in eval
return self.run(node, expr=expr, lineno=lineno, with_raise=raise_errors)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "REDACT\venv\Lib\site-packages\asteval\asteval.py", line 299, in run
self.raise_exception(node, expr=expr)
File "REDACT\venv\Lib\site-packages\asteval\asteval.py", line 242, in raise_exception
raise exc(self.error_msg)
NameError: name 'i_dont_exist' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "REDACT\test.py", line 7, in <module>
interpreter.eval('i_dont_exist', raise_errors=True)
File "REDACT\venv\Lib\site-packages\asteval\asteval.py", line 343, in eval
raise self.error[-1].exc(errmsg) from exc
^^^
NameError: name 'exc' is not defined. Did you mean: 'exec'?
Process finished with exit code 1
Seems there is a reference to an undefined python variable in this case.
Perhaps it needs: except Exception as exc: in the handlers, it seems this error is possible in two places when looking at eval
defeval(self, expr, lineno=0, show_errors=True, raise_errors=False):
"""Evaluate a single statement."""self.lineno=linenoself.error= []
self.start_time=time.time()
ifisinstance(expr, str):
try:
node=self.parse(expr)
exceptException:
errmsg=exc_info()[1]
iflen(self.error) >0:
lerr=self.error[-1]
errmsg=lerr.get_error()[1]
ifraise_errors:
raiselerr.exc(errmsg) fromexc# HERE exc does not existifshow_errors:
print(errmsg, file=self.err_writer)
returnNoneelse:
node=exprtry:
returnself.run(node, expr=expr, lineno=lineno, with_raise=raise_errors)
except:
errmsg=exc_info()[1]
iflen(self.error) >0:
errmsg=self.error[-1].get_error()[1]
ifraise_errors:
raiseself.error[-1].exc(errmsg) fromexc# HERE exc does not existifshow_errors:
print(errmsg, file=self.err_writer)
returnNone
The text was updated successfully, but these errors were encountered:
Teriks
changed the title
NameError oddity,
NameError oddity, undefined python variable reference
Sep 21, 2024
@Teriks Thanks, and sorry for the trouble. #129 and #131 were similar issues.
Apparently, having sensible exceptions and reasonable handling of raise_errors is right at the threshold of my ability to do well ;)
I've updated the code and added a test so that this should now work. I'll choose to be cautiously optimistic but maybe not completely confident this is the end of it ;)
In 1.0.4 I noticed this odd traceback for an undefined identifier.
I am using python 3.12.3
Output:
Seems there is a reference to an undefined python variable in this case.
Perhaps it needs:
except Exception as exc:
in the handlers, it seems this error is possible in two places when looking ateval
The text was updated successfully, but these errors were encountered: