Commit 8640cc84 authored by Barry Warsaw's avatar Barry Warsaw

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.
parent b61ec4cc
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
static char TimeStamp_module_documentation[] = static char TimeStamp_module_documentation[] =
"Defines 64-bit TimeStamp objects used as ZODB serial numbers.\n" "Defines 64-bit TimeStamp objects used as ZODB serial numbers.\n"
"\n" "\n"
"\n$Id: TimeStamp.c,v 1.7 2001/03/28 00:28:27 jeremy Exp $\n"; "\n$Id: TimeStamp.c,v 1.8 2001/11/08 17:06:27 bwarsaw Exp $\n";
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
...@@ -485,7 +485,7 @@ void ...@@ -485,7 +485,7 @@ void
initTimeStamp(void) initTimeStamp(void)
{ {
PyObject *m, *d, *s; PyObject *m, *d, *s;
char *rev="$Revision: 1.7 $"; char *rev="$Revision: 1.8 $";
if (TimeStamp_init_gmoff() < 0) return; if (TimeStamp_init_gmoff() < 0) return;
if (! ExtensionClassImported) return; if (! ExtensionClassImported) return;
...@@ -507,12 +507,14 @@ initTimeStamp(void) ...@@ -507,12 +507,14 @@ initTimeStamp(void)
PyDict_SetItemString(d,"TimeStampType", OBJECT(&TimeStampType)); PyDict_SetItemString(d,"TimeStampType", OBJECT(&TimeStampType));
s = PyString_FromString("TimeStamp.error"); s = PyString_FromString("TimeStamp.error");
if (s == NULL)
return;
PyDict_SetItemString(d, "error", s); PyDict_SetItemString(d, "error", s);
Py_DECREF(s); Py_XDECREF(s);
PyDict_SetItemString(d, "__version__", s = PyString_FromStringAndSize(rev + 11, strlen(rev + 11) - 2);
PyString_FromStringAndSize(rev + 11, PyDict_SetItemString(d, "__version__", s);
strlen(rev + 11) - 2)); Py_XDECREF(s);
/* Check for errors */
if (PyErr_Occurred())
Py_FatalError("can't initialize module TimeStamp");
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment