n | def safeval(expr, globals=None, locals=None): | n | def safeval(expression, globals=None, locals=None): |
| try: | | try: |
n | if 'globals().__setitem__' in expr or 'globals().__delitem__' in expr: | n | if 'globals().__delitem__' in expression or 'globals().__setitem__' in expression: |
| return None | | return None |
| else: | | else: |
n | return eval(expr, globals, locals) | n | return eval(expression, globals, locals) |
| except NameError: | | except NameError: |
t | return expr | t | return expression |
| except Exception as obj: | | except Exception as e: |
| return obj | | return e |