Implement PEP 3121: new module initialization and finalization API.

This commit is contained in:
Martin v. Löwis 2008-06-11 05:26:20 +00:00
parent cdf94635d7
commit 1a21451b1d
113 changed files with 2230 additions and 855 deletions

View file

@ -233,21 +233,35 @@ upon normal program termination.\n\
Two public functions, register and unregister, are defined.\n\
");
static struct PyModuleDef atexitmodule = {
PyModuleDef_HEAD_INIT,
"atexit",
atexit__doc__,
-1,
atexit_methods,
NULL,
NULL,
NULL,
NULL
};
PyMODINIT_FUNC
initatexit(void)
PyInit_atexit(void)
{
PyObject *m;
atexit_callbacks = PyMem_New(atexit_callback*, callback_len);
if (atexit_callbacks == NULL)
return;
return NULL;
m = Py_InitModule3("atexit", atexit_methods, atexit__doc__);
m = PyModule_Create(&atexitmodule);
if (m == NULL)
return;
return NULL;
_Py_PyAtExit(atexit_callfuncs);
/* Register a callback that will free
atexit_callbacks, otherwise valgrind will report memory leaks. */
Py_AtExit(atexit_cleanup);
return m;
}