Message148311
| Author |
kxroberto |
| Recipients |
kxroberto |
| Date |
2011年11月25日.09:02:41 |
| SpamBayes Score |
0.00030608795 |
| Marked as misclassified |
No |
| Message-id |
<1322211763.06.0.781568755806.issue13479@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
When a class definition was re-executed (reload, exec ..) , pickling of existing instances fails for to picky reason (class object id mismatch). Solved by the one liner patch below.
Rational: Python is dynamic. Like with any normal attribute lookup: When its the same module/..name this class is really meant - no matter about its id.
(During unpickling its another id anyway, the code may have evolved years ...)
diff -ur --strip _orig/pickle.py ./pickle.py
--- _orig/pickle.py 2008年09月08日 10:58:32 +0000
+++ ./pickle.py 2011年11月24日 15:47:11 +0000
@@ -747,7 +747,7 @@
"Can't pickle %r: it's not found as %s.%s" %
(obj, module, name))
else:
- if klass is not obj:
+ if klass.__name__ != obj.__name__:
raise PicklingError(
"Can't pickle %r: it's not the same object as %s.%s" %
(obj, module, name)) |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2011年11月25日 09:02:43 | kxroberto | set | recipients:
+ kxroberto |
| 2011年11月25日 09:02:43 | kxroberto | set | messageid: <1322211763.06.0.781568755806.issue13479@psf.upfronthosting.co.za> |
| 2011年11月25日 09:02:42 | kxroberto | link | issue13479 messages |
| 2011年11月25日 09:02:41 | kxroberto | create |
|