[Zope-Checkins] CVS: StandaloneZODB/ZODB - TimeStamp.c:1.8

Barry Warsaw barry@wooz.org
Thu, 8 Nov 2001 12:06:28 -0500


Update of /cvs-repository/StandaloneZODB/ZODB
In directory cvs.zope.org:/tmp/cvs-serv5465/ZODB

Modified Files:
	TimeStamp.c 
Log Message:
initTimeStamp(): Some cleanup of the initializer.  First be sure to
decref the revision string, added to the module dict with the keys
"__version__".  This fixes a small leaks detected by Insure.

Also, instead of returning from the init should the
PyString_FromString() of "TimeStamp.error fail, we simply take
precautions by XDECREF'ing it.  Then at the end of the function, we do
a PyErr_Occurred() check and throw a fatal error if true.  This makes
this module's init function more in line with other init functions in
this package.


=== StandaloneZODB/ZODB/TimeStamp.c 1.7 => 1.8 ===
 
   s = PyString_FromString("TimeStamp.error");
-  if (s == NULL)
-      return;
   PyDict_SetItemString(d, "error", s);
-  Py_DECREF(s);
+  Py_XDECREF(s);
 
-  PyDict_SetItemString(d, "__version__",
-		       PyString_FromStringAndSize(rev + 11, 
-						  strlen(rev + 11) - 2));
+  s = PyString_FromStringAndSize(rev + 11, strlen(rev + 11) - 2);
+  PyDict_SetItemString(d, "__version__", s);
+  Py_XDECREF(s);
+
+  /* Check for errors */
+  if (PyErr_Occurred())
+    Py_FatalError("can't initialize module TimeStamp");
 }