summaryrefslogtreecommitdiffstats
path: root/Modules/atexitmodule.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2008-06-11 05:26:20 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2008-06-11 05:26:20 (GMT)
commit1a21451b1d73b65af949193208372e86bf308411 (patch)
tree8e98d7be9e249b011ae9380479656e5284ec0234 /Modules/atexitmodule.c
parentcdf94635d7e364f9ce1905bafa5b540f4d16147c (diff)
downloadcpython-1a21451b1d73b65af949193208372e86bf308411.zip
cpython-1a21451b1d73b65af949193208372e86bf308411.tar.gz
cpython-1a21451b1d73b65af949193208372e86bf308411.tar.bz2
Implement PEP 3121: new module initialization and finalization API.
Diffstat (limited to 'Modules/atexitmodule.c')
-rw-r--r--Modules/atexitmodule.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/Modules/atexitmodule.c b/Modules/atexitmodule.c
index 60bb932..5b073cb 100644
--- a/Modules/atexitmodule.c
+++ b/Modules/atexitmodule.c
@@ -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;
}