Not all that safe, just catches some errors
(expr: str, namespace: dict[str, Any])
| 40 | |
| 41 | |
| 42 | def safe_eval(expr: str, namespace: dict[str, Any]) -> Any: |
| 43 | """Not all that safe, just catches some errors""" |
| 44 | try: |
| 45 | return eval(expr, namespace) |
| 46 | except (NameError, AttributeError, SyntaxError): |
| 47 | # If debugging safe_eval, raise this! |
| 48 | # raise |
| 49 | raise EvaluationError |
| 50 | |
| 51 | |
| 52 | # This function is under the Python License, Version 2 |
no outgoing calls
no test coverage detected