[Python-Dev] cPickle incompatibility!

Christian Tismer tismer at stackless.com
Tue Feb 24 09:38:20 EST 2004


Hi developers,

while hunting for problems with Stackless pickling,
I found a bug in cPickle.

Pickling of functions:
pickle.py first tries a save_global.
If that doesn't work, it tries a save_reduce.

cPickle doesn't do that.
This bug exists since Python 2.3.

cvs -z9 diff -u -wb cPickle.c (in directory 
D:\cvsdown\python\dist\src\Modules\)
Index: cPickle.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/cPickle.c,v
retrieving revision 2.148
diff -u -w -b -r2.148 cPickle.c
--- cPickle.c	12 Oct 2003 19:09:36 -0000	2.148
+++ cPickle.c	24 Feb 2004 14:28:34 -0000
@@ -2418,6 +2418,11 @@
      case 'f':
          if (type == &PyFunction_Type) {
              res = save_global(self, args, NULL);
+            if (res && PyErr_ExceptionMatches(PickleError)) {
+                /* fall back to reduce */
+                       PyErr_Clear();
+                       break;
+            }
              goto finally;
          }
      break;

May I check this one in? (or somebody else do it)

ciao - chris
-- 
Christian Tismer             :^)   <mailto:tismer at stackless.com>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a     :    *Starship* http://starship.python.net/
14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34  home +49 30 802 86 56  mobile +49 173 24 18 776
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   http://www.stackless.com/





More information about the Python-Dev mailing list