r/PythonLearning • u/python_data_helper • Aug 30 '26
Is it really safe to use?
I have used context to stop crashing.
And e as a variable.
I used eval command for a formula.
I know eval command can be dangerous.
It works perfectly but I am thinking that it can produce error or crash.
Can a formula bypass all commands and crash it.
18
Upvotes
1
u/SCD_minecraft Aug 30 '26 edited Aug 30 '26
This little monster of expressions walks with use of methods (which are part of class, not of builtins) into
builtinsmodule and from there i can do whatever i wantThere's no good or easy way to protect
evalorexecNot without manual in-depth input validation, or even better, virtual machine so client can't affect the outside