Commit a94c1c48 authored by Barry Warsaw's avatar Barry Warsaw

initcoptimizations(): 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, 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 bb773b12
......@@ -318,8 +318,8 @@ static struct PyMethodDef Module_Level__methods[] = {
void
initcoptimizations(void)
{
PyObject *m, *d;
char *rev="$Revision: 1.12 $";
PyObject *m, *d, *s;
char *rev="$Revision: 1.13 $";
#define make_string(S) if (! (py_ ## S=PyString_FromString(#S))) return
make_string(_p_oid);
......@@ -348,6 +348,11 @@ initcoptimizations(void)
persistent_idType.ob_type=&PyType_Type;
PyDict_SetItemString(d,"persistent_idType", OBJECT(&persistent_idType));
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 coptimizations");
}
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