[ python-Bugs-903483 ] cPickle/pickle incompatibility

SourceForge.net noreply at sourceforge.net
Thu Feb 26 11:28:03 EST 2004


Bugs item #903483, was opened at 2004-02-24 15:59
Message generated for change (Settings changed) made by tismer
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=903483&group_id=5470

Category: Extension Modules
Group: Python 2.3
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Christian Tismer (tismer)
Assigned to: Christian Tismer (tismer)
Summary: cPickle/pickle incompatibility

Initial Comment:
Pickling of functions:
pickle.py first tries a save_global.
If that doesn't work, it tries a save_reduce.
This fallback allows to register pickling of local
functions
via copy_reg.

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

Solution:
A simple patch allows cPickle to fall back to reduce as
well.

Range:
I think this patch should be applied back to Python 2.3.


----------------------------------------------------------------------

Comment By: Christian Tismer (tismer)
Date: 2004-02-24 16:06

Message:
Logged In: YES 
user_id=105700

Here the obvious patch:

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;


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=903483&group_id=5470



More information about the Python-bugs-list mailing list