##// END OF EJS Templates
still allow @interactive on Classes
MinRK -
Show More
@@ -222,16 +222,17 b' def interactive(f):'
222 This results in the function being linked to the user_ns as globals()
222 This results in the function being linked to the user_ns as globals()
223 instead of the module globals().
223 instead of the module globals().
224 """
224 """
225 mainmod = __import__('__main__')
226
225
227 # build new FunctionType, so it can have the right globals
226 # build new FunctionType, so it can have the right globals
228 # interactive functions never have closures, that's kind of the point
227 # interactive functions never have closures, that's kind of the point
229 f2 = FunctionType(f.__code__, mainmod.__dict__,
228 if isinstance(f, FunctionType):
230 f.__name__, f.__defaults__,
229 mainmod = __import__('__main__')
231 )
230 f = FunctionType(f.__code__, mainmod.__dict__,
231 f.__name__, f.__defaults__,
232 )
232 # associate with __main__ for uncanning
233 # associate with __main__ for uncanning
233 f2.__module__ = '__main__'
234 f.__module__ = '__main__'
234 return f2
235 return f
235
236
236 @interactive
237 @interactive
237 def _push(**ns):
238 def _push(**ns):
General Comments 0
You need to be logged in to leave comments. Login now