New submission from Greg Kochanski <[EMAIL PROTECTED]>: If you attempt to cPickle a class, cPickle checks that it can get the identical class by importing it.
If that check fails, it reports: Traceback (most recent call last): ... "/usr/local/lib/python2.5/site-packages/newstem2-0.12.3-py2.5-linux-i686.egg/newstem2/stepperclient.py", line 41, in send s = cPickle.dumps( args, cPickle.HIGHEST_PROTOCOL) cPickle.PicklingError: Can't pickle <class 'test_simple2.aModel'>: it's not the same object as test_simple2.aModel $ Normally, this is probably a good thing. However, if you do an import using the "imp" module, via imp.load_module(name, fd, pn, desc), you get the "same" module containing the "same" classes, but everything is duplicated at different addresses. In other words, you get distinct class objects from what cPickle will find. Consequently, the when cPickle makes the "is" comparison between what you gave it and what it can find, it will fail and cause an error. In this case, the error is wrong. I know that the aModel classes come from the same file and are member-for-member the same. This may well be a documentation error: it needs to mention this test and note that classes in modules imported via imp are not picklable. Or, imp needs to note that its results are not picklable. Or both. Or, maybe it's something that should be fixed, though I'm not sure if there is a general solution that will always behave well. ---------- assignee: georg.brandl components: Documentation, Library (Lib) messages: 63560 nosy: georg.brandl, gpk severity: normal status: open title: cPickle corner case - docs or bug? type: behavior versions: Python 2.5 __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2295> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com