[Zodb-checkins] CVS: Zope3/src/persistence - persistence.c:1.16

Jeremy Hylton jeremy at zope.com
Wed May 7 10:11:25 EDT 2003


Update of /cvs-repository/Zope3/src/persistence
In directory cvs.zope.org:/tmp/cvs-serv14897

Modified Files:
	persistence.c 
Log Message:
Preserve _p_serial across __setstate__().
Fix test of class with __slots__ to include _p_serial in __slots__.


=== Zope3/src/persistence/persistence.c 1.15 => 1.16 ===
--- Zope3/src/persistence/persistence.c:1.15	Mon May  5 13:06:27 2003
+++ Zope3/src/persistence/persistence.c	Wed May  7 09:10:53 2003
@@ -175,6 +175,8 @@
     PyObject **pdict;
     PyObject *dict;
     PyObject *k, *v;
+    PyObject *serial = NULL;
+    static PyObject *_p_serial;
     int pos = 0;
 
     if (state == Py_None) {
@@ -189,8 +191,14 @@
 	if ((*pdict) == NULL)
 	    return NULL;
     }
-    else
+    else {
+	if (!_p_serial) {
+	    _p_serial = PyString_InternFromString("_p_serial");
+	}
+	serial = PyDict_GetItem(*pdict, _p_serial);
+	Py_XINCREF(serial);
 	PyDict_Clear(*pdict);
+    }
     dict = *pdict;
     
     if (!PyDict_Check(state)) {
@@ -206,6 +214,11 @@
 	}
 	if (PyDict_SetItem(dict, k, v) < 0)
 	    return NULL;
+    }
+    if (serial) {
+	if (PyDict_SetItem(*pdict, _p_serial, serial) < 0)
+	    return NULL;
+	Py_DECREF(serial);
     }
 
     Py_INCREF(Py_None);




More information about the Zodb-checkins mailing list