Skip to content
Snippets Groups Projects
Commit 46ef1356 authored by Denis Ledoux's avatar Denis Ledoux
Browse files

[ADD] safe_eval: UNPACK_SEQUENCE and Exception

Allowing UNPACK_SEQUENCE allows the use of the "multi" assignation:
a, b = [1,2]
for a,b in items
parent 133becd9
Branches
Tags
No related merge requests found
......@@ -67,7 +67,7 @@ _SAFE_OPCODES = _EXPR_OPCODES.union(set(opmap[x] for x in [
# New in Python 2.7 - http://bugs.python.org/issue4715 :
'JUMP_IF_FALSE_OR_POP', 'JUMP_IF_TRUE_OR_POP', 'POP_JUMP_IF_FALSE',
'POP_JUMP_IF_TRUE', 'SETUP_EXCEPT', 'END_FINALLY',
'LOAD_FAST', 'STORE_FAST', 'DELETE_FAST',
'LOAD_FAST', 'STORE_FAST', 'DELETE_FAST', 'UNPACK_SEQUENCE',
'LOAD_GLOBAL', # Only allows access to restricted globals
] if x in opmap))
......@@ -278,7 +278,8 @@ def safe_eval(expr, globals_dict=None, locals_dict=None, mode="eval", nocopy=Fal
'filter': filter,
'round': round,
'len': len,
'set' : set
'set' : set,
'Exception': Exception,
}
)
try:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment