[Zope-Checkins] CVS: Zope2 - cPersistence.c:1.43

Jim Fulton jim@digicool.com
Wed, 28 Mar 2001 09:04:17 -0500 (EST)


Update of /cvs-repository/Zope2/lib/python/ZODB
In directory korak:/tmp/cvs-serv16979

Modified Files:
	cPersistence.c 
Log Message:
Undid a previous change, which broke all extensions that defined
persistent base classes (e.g. BTrees.)

Also added error checking for code that performs initialization of
some global string objects.



--- Updated File cPersistence.c in package Zope2/lib/python/ZODB --
--- cPersistence.c	2001/03/28 00:34:34	1.42
+++ cPersistence.c	2001/03/28 14:04:15	1.43
@@ -95,8 +95,6 @@
 #define UNLESS_ASSIGN(V,E) ASSIGN(V,E) UNLESS(V)
 #define OBJECT(V) ((PyObject*)(V))
 
-static cPersistenceCAPIstruct *cPersistenceCAPI;
-
 static PyObject *py_keys, *py_setstate, *py___dict__, *py_timeTime;
 static PyObject *py__p_changed, *py__p_deactivate;
 static PyObject *py___getattr__, *py___setattr__, *py___delattr__;
@@ -122,10 +120,10 @@
 }
 #endif
 
-static void
+static int
 init_strings(void)
 {
-#define INIT_STRING(S) py_ ## S = PyString_FromString(#S)
+#define INIT_STRING(S) if (! (py_ ## S = PyString_FromString(#S))) return -1;
   INIT_STRING(keys);
   INIT_STRING(setstate);
   INIT_STRING(timeTime);
@@ -136,6 +134,7 @@
   INIT_STRING(__setattr__);
   INIT_STRING(__delattr__);
 #undef INIT_STRING
+  return 0;
 }
 
 static PyObject *
@@ -756,10 +755,11 @@
       Py_DECREF(s);
   }
 
+  if (init_strings() < 0) return;
+
   m = Py_InitModule4("cPersistence", cP_methods, cPersistence_doc_string,
 		     (PyObject*)NULL, PYTHON_API_VERSION);
 
-  init_strings();
   
   d = PyModule_GetDict(m);
   PyDict_SetItemString(d,"__version__",



--- Updated File cPersistence.c in package Zope2 --
--- cPersistence.c	2001/03/28 00:34:34	1.42
+++ cPersistence.c	2001/03/28 14:04:15	1.43
@@ -95,8 +95,6 @@
 #define UNLESS_ASSIGN(V,E) ASSIGN(V,E) UNLESS(V)
 #define OBJECT(V) ((PyObject*)(V))
 
-static cPersistenceCAPIstruct *cPersistenceCAPI;
-
 static PyObject *py_keys, *py_setstate, *py___dict__, *py_timeTime;
 static PyObject *py__p_changed, *py__p_deactivate;
 static PyObject *py___getattr__, *py___setattr__, *py___delattr__;
@@ -122,10 +120,10 @@
 }
 #endif
 
-static void
+static int
 init_strings(void)
 {
-#define INIT_STRING(S) py_ ## S = PyString_FromString(#S)
+#define INIT_STRING(S) if (! (py_ ## S = PyString_FromString(#S))) return -1;
   INIT_STRING(keys);
   INIT_STRING(setstate);
   INIT_STRING(timeTime);
@@ -136,6 +134,7 @@
   INIT_STRING(__setattr__);
   INIT_STRING(__delattr__);
 #undef INIT_STRING
+  return 0;
 }
 
 static PyObject *
@@ -756,10 +755,11 @@
       Py_DECREF(s);
   }
 
+  if (init_strings() < 0) return;
+
   m = Py_InitModule4("cPersistence", cP_methods, cPersistence_doc_string,
 		     (PyObject*)NULL, PYTHON_API_VERSION);
 
-  init_strings();
   
   d = PyModule_GetDict(m);
   PyDict_SetItemString(d,"__version__",