]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Given the persistent id code a shot at a class before calling save_global().
authorJeremy Hylton <jeremy@alum.mit.edu>
Tue, 16 Jul 2002 20:02:15 +0000 (20:02 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Tue, 16 Jul 2002 20:02:15 +0000 (20:02 +0000)
Backported from the trunk.

Lib/pickle.py
Modules/cPickle.c

index eb360dd8f4c62330486fa61fd3c80f4bd606f879..38bda79fc566a62c53ba448e74c1e37d48b9193b 100644 (file)
@@ -163,6 +163,11 @@ class Pickler:
         try:
             f = self.dispatch[t]
         except KeyError:
+            pid = self.inst_persistent_id(object)
+            if pid is not None:
+                self.save_pers(pid)
+                return
+
             try:
                 issc = issubclass(t, TypeType)
             except TypeError: # t is not a class
@@ -171,11 +176,6 @@ class Pickler:
                 self.save_global(object)
                 return
 
-            pid = self.inst_persistent_id(object)
-            if pid is not None:
-                self.save_pers(pid)
-                return
-
             try:
                 reduce = dispatch_table[t]
             except KeyError:
index adf7e4449f0241417ae859cfa7707a44f1358448..1f8b210ede4f12f7d9713a00a53996c0e2de0763 100644 (file)
@@ -1992,11 +1992,6 @@ save(Picklerobject *self, PyObject *args, int  pers_save) {
             }
     }
 
-    if (PyType_IsSubtype(type, &PyType_Type)) {
-       res = save_global(self, args, NULL);
-       goto finally;
-    }
-
     if (!pers_save && self->inst_pers_func) {
         if ((tmp = save_pers(self, args, self->inst_pers_func)) != 0) {
             res = tmp;
@@ -2004,6 +1999,11 @@ save(Picklerobject *self, PyObject *args, int  pers_save) {
         }
     }
 
+    if (PyType_IsSubtype(type, &PyType_Type)) {
+       res = save_global(self, args, NULL);
+       goto finally;
+    }
+
     if ((__reduce__ = PyDict_GetItem(dispatch_table, (PyObject *)type))) {
         Py_INCREF(__reduce__);