summaryrefslogtreecommitdiffstats
path: root/Modules/arraymodule.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/arraymodule.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/arraymodule.c')
-rw-r--r--Modules/arraymodule.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index ea59a42..5fa525f 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -2156,9 +2156,21 @@ static PyMethodDef a_methods[] = {
{NULL, NULL, 0, NULL} /* Sentinel */
};
+static struct PyModuleDef arraymodule = {
+ PyModuleDef_HEAD_INIT,
+ "array",
+ module_doc,
+ -1,
+ a_methods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
PyMODINIT_FUNC
-initarray(void)
+PyInit_array(void)
{
PyObject *m;
PyObject *typecodes;
@@ -2167,11 +2179,11 @@ initarray(void)
struct arraydescr *descr;
if (PyType_Ready(&Arraytype) < 0)
- return;
+ return NULL;
Py_TYPE(&PyArrayIter_Type) = &PyType_Type;
- m = Py_InitModule3("array", a_methods, module_doc);
+ m = PyModule_Create(&arraymodule);
if (m == NULL)
- return;
+ return NULL;
Py_INCREF((PyObject *)&Arraytype);
PyModule_AddObject(m, "ArrayType", (PyObject *)&Arraytype);
@@ -2190,5 +2202,9 @@ initarray(void)
PyModule_AddObject(m, "typecodes", (PyObject *)typecodes);
- /* No need to check the error here, the caller will do that */
+ if (PyErr_Occurred()) {
+ Py_DECREF(m);
+ m = NULL;
+ }
+ return m;
}