summaryrefslogtreecommitdiffstats
path: root/Modules/_functoolsmodule.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/_functoolsmodule.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/_functoolsmodule.c')
-rw-r--r--Modules/_functoolsmodule.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c
index 167f906..731d028 100644
--- a/Modules/_functoolsmodule.c
+++ b/Modules/_functoolsmodule.c
@@ -326,8 +326,21 @@ static PyMethodDef module_methods[] = {
{NULL, NULL} /* sentinel */
};
+
+static struct PyModuleDef _functoolsmodule = {
+ PyModuleDef_HEAD_INIT,
+ "_functools",
+ module_doc,
+ -1,
+ module_methods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
PyMODINIT_FUNC
-init_functools(void)
+PyInit__functools(void)
{
int i;
PyObject *m;
@@ -337,16 +350,19 @@ init_functools(void)
NULL
};
- m = Py_InitModule3("_functools", module_methods, module_doc);
+ m = PyModule_Create(&_functoolsmodule);
if (m == NULL)
- return;
+ return NULL;
for (i=0 ; typelist[i] != NULL ; i++) {
- if (PyType_Ready(typelist[i]) < 0)
- return;
+ if (PyType_Ready(typelist[i]) < 0) {
+ Py_DECREF(m);
+ return NULL;
+ }
name = strchr(typelist[i]->tp_name, '.');
assert (name != NULL);
Py_INCREF(typelist[i]);
PyModule_AddObject(m, name+1, (PyObject *)typelist[i]);
}
+ return m;
}