[Zodb-checkins] CVS: ZODB3/persistent - cPersistence.c:1.75.2.3

Fred L. Drake, Jr. fred at zope.com
Fri Jan 16 12:08:46 EST 2004


Update of /cvs-repository/ZODB3/persistent
In directory cvs.zope.org:/tmp/cvs-serv2755

Modified Files:
      Tag: zope3-zodb3-devel-branch
	cPersistence.c 
Log Message:
- simplify code to add state constants to the module
- be more careful initializing TimeStamp in the face of reload(), and
  don't leak a reference if there's an error


=== ZODB3/persistent/cPersistence.c 1.75.2.2 => 1.75.2.3 ===
--- ZODB3/persistent/cPersistence.c:1.75.2.2	Fri Jan 16 10:43:28 2004
+++ ZODB3/persistent/cPersistence.c	Fri Jan 16 12:08:45 2004
@@ -744,33 +744,25 @@
     if (PyModule_AddObject(m, "CAPI", s) < 0)
 	return;
 
-    if (PyModule_AddObject(m, 
-                           "GHOST", 
-                           PyInt_FromLong(cPersistent_GHOST_STATE)
-                           ) < 0)
+    if (PyModule_AddIntConstant(m, "GHOST", cPersistent_GHOST_STATE) < 0)
 	return;
 
-    if (PyModule_AddObject(m, 
-                           "UPTODATE", 
-                           PyInt_FromLong(cPersistent_UPTODATE_STATE)
-                           ) < 0)
+    if (PyModule_AddIntConstant(m, "UPTODATE", cPersistent_UPTODATE_STATE) < 0)
 	return;
 
-    if (PyModule_AddObject(m, 
-                           "CHANGED", 
-                           PyInt_FromLong(cPersistent_CHANGED_STATE)
-                           ) < 0)
+    if (PyModule_AddIntConstant(m, "CHANGED", cPersistent_CHANGED_STATE) < 0)
 	return;
 
     py_simple_new = PyObject_GetAttrString(m, "simple_new");
     if (!py_simple_new)
         return;
 
-    m = PyImport_ImportModule("persistent.TimeStamp");
-    if (!m)
-	return;
-    TimeStamp = PyObject_GetAttrString(m, "TimeStamp");
-    if (!TimeStamp)
-	return;
-    Py_DECREF(m);
+    if (TimeStamp == NULL) {
+        m = PyImport_ImportModule("persistent.TimeStamp");
+        if (!m)
+	    return;
+        TimeStamp = PyObject_GetAttrString(m, "TimeStamp");
+        Py_DECREF(m);
+        /* fall through to immediate return on error */
+    }
 }




More information about the Zodb-checkins mailing list