From 69f00e0566536c2e1d43f69f7b32fbd7d39d2f3a 2012-07-26 05:34:30 From: MinRK Date: 2012-07-26 05:34:30 Subject: [PATCH] can func_defaults allows passing interactively defined functions as func_defaults --- diff --git a/IPython/utils/pickleutil.py b/IPython/utils/pickleutil.py index 0b02db8..ed5585c 100644 --- a/IPython/utils/pickleutil.py +++ b/IPython/utils/pickleutil.py @@ -84,7 +84,10 @@ class CannedFunction(CannedObject): def __init__(self, f): self._check_type(f) self.code = f.func_code - self.defaults = f.func_defaults + if f.func_defaults: + self.defaults = [ can(fd) for fd in f.func_defaults ] + else: + self.defaults = None self.module = f.__module__ or '__main__' self.__name__ = f.__name__ self.buffers = [] @@ -104,7 +107,11 @@ class CannedFunction(CannedObject): if g is None: g = {} - newFunc = FunctionType(self.code, g, self.__name__, self.defaults) + if self.defaults: + defaults = tuple(uncan(cfd, g) for cfd in self.defaults) + else: + defaults = None + newFunc = FunctionType(self.code, g, self.__name__, defaults) return newFunc