##// END OF EJS Templates
make @interactive decorator friendlier with dill...
MinRK -
Show More
@@ -27,6 +27,7 b' try:'
27 27 from signal import SIGKILL
28 28 except ImportError:
29 29 SIGKILL=None
30 from types import FunctionType
30 31
31 32 try:
32 33 import cPickle
@@ -221,8 +222,16 b' def interactive(f):'
221 222 This results in the function being linked to the user_ns as globals()
222 223 instead of the module globals().
223 224 """
224 f.__module__ = '__main__'
225 return f
225 mainmod = __import__('__main__')
226
227 # build new FunctionType, so it can have the right globals
228 # interactive functions never have closures, that's kind of the point
229 f2 = FunctionType(f.__code__, mainmod.__dict__,
230 f.__name__, f.__defaults__,
231 )
232 # associate with __main__ for uncanning
233 f2.__module__ = '__main__'
234 return f2
226 235
227 236 @interactive
228 237 def _push(**ns):
General Comments 0
You need to be logged in to leave comments. Login now