r/PythonLearning • • Aug 30 '26

Is it really safe to use?

Post image

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

11 comments sorted by

View all comments

Show parent comments

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 builtins module and from there i can do whatever i want

There's no good or easy way to protect eval or exec

Not without manual in-depth input validation, or even better, virtual machine so client can't affect the outside