]> granicus.if.org Git - python/commitdiff
made cPickle fall back to the copy_reg/reduce protocol,
authorChristian Tismer <tismer@stackless.com>
Thu, 26 Feb 2004 16:21:45 +0000 (16:21 +0000)
committerChristian Tismer <tismer@stackless.com>
Thu, 26 Feb 2004 16:21:45 +0000 (16:21 +0000)
if a function cannot be stored as global.
This is for compatibility with pickle.py .

Modules/cPickle.c

index 4961c3b36beb893c19ad4d78eb3e256eafe4986c..105a2e9a03504579b8aff318d172aeea833adeb7 100644 (file)
@@ -2418,6 +2418,11 @@ save(Picklerobject *self, PyObject *args, int pers_save)
         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;