This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
| Author | gpk |
|---|---|
| Recipients | georg.brandl, gpk |
| Date | 2008年03月15日.19:18:43 |
| SpamBayes Score | 0.19994602 |
| Marked as misclassified | No |
| Message-id | <1205608726.73.0.310899298914.issue2295@psf.upfronthosting.co.za> |
| In-reply-to |
| Content | |
|---|---|
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. |
|
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2008年03月15日 19:18:47 | gpk | set | spambayes_score: 0.199946 -> 0.19994602 recipients: + gpk, georg.brandl |
| 2008年03月15日 19:18:46 | gpk | set | spambayes_score: 0.199946 -> 0.199946 messageid: <1205608726.73.0.310899298914.issue2295@psf.upfronthosting.co.za> |
| 2008年03月15日 19:18:44 | gpk | link | issue2295 messages |
| 2008年03月15日 19:18:43 | gpk | create | |