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/cjkcodecs/multibytecodec.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/cjkcodecs/multibytecodec.c')
-rw-r--r-- | Modules/cjkcodecs/multibytecodec.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c index 26dd8dd..546f4e2 100644 --- a/Modules/cjkcodecs/multibytecodec.c +++ b/Modules/cjkcodecs/multibytecodec.c @@ -1778,8 +1778,21 @@ static struct PyMethodDef __methods[] = { {NULL, NULL}, }; + +static struct PyModuleDef _multibytecodecmodule = { + PyModuleDef_HEAD_INIT, + "_multibytecodec", + NULL, + -1, + __methods, + NULL, + NULL, + NULL, + NULL +}; + PyMODINIT_FUNC -init_multibytecodec(void) +PyInit__multibytecodec(void) { int i; PyObject *m; @@ -1792,20 +1805,24 @@ init_multibytecodec(void) }; if (PyType_Ready(&MultibyteCodec_Type) < 0) - return; + return NULL; - m = Py_InitModule("_multibytecodec", __methods); + m = PyModule_Create(&_multibytecodecmodule); if (m == NULL) - return; + return NULL; for (i = 0; typelist[i] != NULL; i++) { if (PyType_Ready(typelist[i]) < 0) - return; + return NULL; Py_INCREF(typelist[i]); PyModule_AddObject(m, typelist[i]->tp_name, (PyObject *)typelist[i]); } - if (PyErr_Occurred()) + if (PyErr_Occurred()) { Py_FatalError("can't initialize the _multibytecodec module"); + Py_DECREF(m); + m = NULL; + } + return m; } |