summaryrefslogtreecommitdiffstats
path: root/Modules/operator.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/operator.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/operator.c')
-rw-r--r--Modules/operator.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/Modules/operator.c b/Modules/operator.c
index e86bccf..d31b178 100644
--- a/Modules/operator.c
+++ b/Modules/operator.c
@@ -688,31 +688,44 @@ static PyTypeObject methodcaller_type = {
};
-/* Initialization function for the module (*must* be called initoperator) */
+/* Initialization function for the module (*must* be called PyInit_operator) */
+
+
+static struct PyModuleDef operatormodule = {
+ PyModuleDef_HEAD_INIT,
+ "operator",
+ operator_doc,
+ -1,
+ operator_methods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
PyMODINIT_FUNC
-initoperator(void)
+PyInit_operator(void)
{
PyObject *m;
/* Create the module and add the functions */
- m = Py_InitModule4("operator", operator_methods, operator_doc,
- (PyObject*)NULL, PYTHON_API_VERSION);
+ m = PyModule_Create(&operatormodule);
if (m == NULL)
- return;
+ return NULL;
if (PyType_Ready(&itemgetter_type) < 0)
- return;
+ return NULL;
Py_INCREF(&itemgetter_type);
PyModule_AddObject(m, "itemgetter", (PyObject *)&itemgetter_type);
if (PyType_Ready(&attrgetter_type) < 0)
- return;
+ return NULL;
Py_INCREF(&attrgetter_type);
PyModule_AddObject(m, "attrgetter", (PyObject *)&attrgetter_type);
if (PyType_Ready(&methodcaller_type) < 0)
- return;
+ return NULL;
Py_INCREF(&methodcaller_type);
PyModule_AddObject(m, "methodcaller", (PyObject *)&methodcaller_type);
+ return m;
}