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.

classification
Title: cPickle/pickle incompatibility
Type: Stage:
Components: Extension Modules Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: tismer Nosy List: tismer
Priority: normal Keywords:

Created on 2004-02-24 14:59 by tismer, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg20131 - (view) Author: Christian Tismer (old) (tismer) Date: 2004-02-24 14:59
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.
msg20132 - (view) Author: Christian Tismer (old) (tismer) Date: 2004-02-24 15:06
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;
History
Date User Action Args
2022-04-11 14:56:02adminsetgithub: 39980
2004-02-24 14:59:01tismercreate