Skip to content

Commit

Permalink
Merge 76951e6 into aada1f4
Browse files Browse the repository at this point in the history
  • Loading branch information
shughes-uk committed Jan 9, 2020
2 parents aada1f4 + 76951e6 commit ac8f3ad
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion simpleeval.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,21 @@
# people not be stupid. Allowing these functions opens up all sorts of holes - if any of
# their functionality is required, then please wrap them up in a safe container. And think
# very hard about it first. And don't say I didn't warn you.
if isinstance(__builtins__, dict) and 'help' in __builtins__: # builtins is a dict in python >3.6 but a module before
DISALLOW_FUNCTIONS = {
type, isinstance, eval, getattr, setattr, help, repr, compile, open
}
elif 'help' in dir(__builtins__):
DISALLOW_FUNCTIONS = {
type, isinstance, eval, getattr, setattr, help, repr, compile, open
}
else:
print('help not in builtins')

DISALLOW_FUNCTIONS = {
type, isinstance, eval, getattr, setattr, repr, compile, open
}

DISALLOW_FUNCTIONS = {type, isinstance, eval, getattr, setattr, help, repr, compile, open}

if PYTHON3:
exec('DISALLOW_FUNCTIONS.add(exec)') # exec is not a function in Python2...
Expand Down

0 comments on commit ac8f3ad

Please sign in to comment.