[IPython-dev] [Fwd: [afayolle at debian.org: Bug#374625: python2.3-ipython: help built-in function does not work]]

Ville Vainio vivainio at gmail.com
Thu Aug 10 13:45:23 CDT 2006


On 8/10/06, Fernando Perez <fperez.net at gmail.com> wrote:

> No, FakeModule is much, much older.  I wrote that code years ago,

Yeah, rev 8 in fact.
> patches until then.  But for testing purposes, try various
> combinations of pickling reasonably complex things from the command
> line and unpickling them, and do so crossing boundaries between
> pickling things interactively and unpickling them from a pure python
> script (run without ipython) and viceversa.  There's a chance the
> problem was some kind of bad interaction between pickling in ipython
> and unpickling elsewhere.

It's almost certain that every instance from non-__main__ module
pickles correctly b/w python and ipython.

In %run, the following works correctly w/ fm2.diff patch:

class C:
    def hi(self):
        self.a = 10

c = C()

import pickle
pickle.dump(c,open("a.pickle","w"))
print pickle.load(open("a.pickle"))

However, that one fails in interactive prompt because InteractiveShell
thinks it's in FakeModule (iplib.py line 317) and with fm2.diff, the
user_ns != FakeModule.__dict__ and unpickle fails with:

/usr/lib/python2.3/pickle.py in find_class(self, module, name)
   1138         __import__(module)
   1139         mod = sys.modules[module]
-> 1140         klass = getattr(mod, name)
   1141         return klass
   1142

AttributeError: 'FakeModule' object has no attribute 'C'

It's a hard call, but I guess this is functionality we *could* afford
to lose, esp. if it fixes inspect.py problems. I'll still try to make
this work though.

-- 
Ville Vainio - vivainio.googlepages.com
vainio.blogspot.com - g[mail | talk]='vivainio'


More information about the IPython-dev mailing list