MCPcopy Index your code
hub / github.com/bpython/bpython / safe_eval

Function safe_eval

bpython/simpleeval.py:42–49  ·  view source on GitHub ↗

Not all that safe, just catches some errors

(expr: str, namespace: dict[str, Any])

Source from the content-addressed store, hash-verified

40
41
42def 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

Callers 2

attr_matchesMethod · 0.85
matchesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected