[SciPy-User] RuntimeError: cannot unmarshal code objects in restricted execution mode

Vladimír Černý blackvladimir at gmail.com
Thu Dec 8 15:23:05 EST 2011


Hi,

when i import scipy in restricted mode (eval function, with changed  
builtins) it ends with exception:

RuntimeError: cannot unmarshal code objects in restricted execution mode.

On the second try it works without exception.

Code to reproduce error:

myb = {}
for b in dir(__builtins__):
   myb[b]=getattr(__builtins__,b)
gl=dict()
gl['__builtins__'] = myb
c=compile('import scipy','file','exec')
eval(c,gl)

This works but i don't know why:

myb = {}
for b in dir(__builtins__):
   myb[b]=getattr(__builtins__,b)
gl=dict()
gl['__builtins__'] = myb
c=compile('import scipy','file','exec')
try:
   eval(c,gl)
except RuntimeError:
   eval(c,gl)


How can i do it without the second try?

Vladimir



More information about the SciPy-User mailing list