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
When giving simpleeval an empty string it raises this error:
Traceback (most recent call last):
Traceback (most recent call last):
File "simpleeval.py", line 613, in simple_eval
return s.eval(expr)
File "simpleeval.py", line 334, in eval
return self._eval(parsed.body[0].value)
IndexError: list index out of range
I propose to either throw an appropriate error or maybe return something. Wether that'd be an empty string or None is too philosophical for me but maybe there's an PIP on this? Anyways, something like this should suffice:
parsed = ast.parse(expr.strip())
if len(parsed.body) > 0:
# and evaluate if not empty:
return self._eval(parsed.body[0].value)
else:
return None
The text was updated successfully, but these errors were encountered:
When giving simpleeval an empty string it raises this error:
Traceback (most recent call last):
I propose to either throw an appropriate error or maybe return something. Wether that'd be an empty string or
None
is too philosophical for me but maybe there's an PIP on this? Anyways, something like this should suffice:The text was updated successfully, but these errors were encountered: