[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
This commit is contained in:
parent
133becd966
commit
46ef1356d6
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue