diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2008-06-11 05:26:20 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2008-06-11 05:26:20 (GMT) |
commit | 1a21451b1d73b65af949193208372e86bf308411 (patch) | |
tree | 8e98d7be9e249b011ae9380479656e5284ec0234 /Modules/arraymodule.c | |
parent | cdf94635d7e364f9ce1905bafa5b540f4d16147c (diff) | |
download | cpython-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.c | 26 |
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; } |