lmfit / asteval

minimalistic evaluator of python expression using ast module
https://lmfit.github.io/asteval
MIT License
183 stars 41 forks source link

Duplicated NameError in 1.0.2? #132

Closed ns-rorsten closed 1 month ago

ns-rorsten commented 2 months ago

In a project using asteval, a test that creates a NameError started failing with a doubled error count when I upgraded to 1.0.2. I see this addressed a problem with NameError handling, but:

In [1]: import asteval

In [2]: interpreter = asteval.Interpreter(nested_symtable=False, use_numpy=False)

In [3]: interpreter.run("print(hi)", with_raise=False)

In [4]: print([e.get_error() for e in interpreter.error])
[('NameError', "   print(hi)\n          ^^^^\nNameError: name 'hi' is not defined"), ('NameError', "   print(hi)\n          ^^^^\nNameError: name 'hi' is not defined")]

For comparison, after downgrading to 1.0.1:

In [1]: import asteval

In [2]: interpreter = asteval.Interpreter(nested_symtable=False, use_numpy=False)

In [3]: interpreter.run("print(hi)", with_raise=False)

In [4]: print([e.get_error() for e in interpreter.error])
[('NameError', "   print(hi)\n          ^^^\nname 'hi' is not defined")]
newville commented 2 months ago

@ns-rorsten Hm, I'll say both "I'm not sure why that is", and "well, better twice than never". ;).

I'll look in to it.

newville commented 1 month ago

@ns-rorsten I think this is now fixed in the master development branch. Once tests all pass, I'll tag a new release.

ns-rorsten commented 1 month ago

Excellent, thank you for the quick response.

newville commented 1 month ago

@ns-rorsten This should now be fixed.