mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Implement PEP 3121: new module initialization and finalization API.
This commit is contained in:
parent
cdf94635d7
commit
1a21451b1d
113 changed files with 2230 additions and 855 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue