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