From 8cef997600e0abfcbd78ba1e406b1396adaabc54 2013-12-17 22:59:19 From: MinRK Date: 2013-12-17 22:59:19 Subject: [PATCH] still allow @interactive on Classes --- diff --git a/IPython/parallel/util.py b/IPython/parallel/util.py index a688d1d..a3b011f 100644 --- a/IPython/parallel/util.py +++ b/IPython/parallel/util.py @@ -222,16 +222,17 @@ def interactive(f): This results in the function being linked to the user_ns as globals() instead of the module globals(). """ - mainmod = __import__('__main__') # build new FunctionType, so it can have the right globals # interactive functions never have closures, that's kind of the point - f2 = FunctionType(f.__code__, mainmod.__dict__, - f.__name__, f.__defaults__, - ) + if isinstance(f, FunctionType): + mainmod = __import__('__main__') + f = FunctionType(f.__code__, mainmod.__dict__, + f.__name__, f.__defaults__, + ) # associate with __main__ for uncanning - f2.__module__ = '__main__' - return f2 + f.__module__ = '__main__' + return f @interactive def _push(**ns):