summaryrefslogtreecommitdiffstats
path: root/Modules/pyexpat.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/pyexpat.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/pyexpat.c')
-rw-r--r--Modules/pyexpat.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index fcd44c3..92fc753 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -1751,7 +1751,7 @@ get_version_string(void)
#endif
#ifndef MODULE_INITFUNC
-#define MODULE_INITFUNC initpyexpat
+#define MODULE_INITFUNC PyInit_pyexpat
#endif
#ifndef PyMODINIT_FUNC
@@ -1764,6 +1764,18 @@ get_version_string(void)
PyMODINIT_FUNC MODULE_INITFUNC(void); /* avoid compiler warnings */
+static struct PyModuleDef pyexpatmodule = {
+ PyModuleDef_HEAD_INIT,
+ MODULE_NAME,
+ pyexpat_module_documentation,
+ -1,
+ pyexpat_methods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
PyMODINIT_FUNC
MODULE_INITFUNC(void)
{
@@ -1777,25 +1789,24 @@ MODULE_INITFUNC(void)
PyObject* capi_object;
if (errmod_name == NULL)
- return;
+ return NULL;
modelmod_name = PyUnicode_FromString(MODULE_NAME ".model");
if (modelmod_name == NULL)
- return;
+ return NULL;
Py_TYPE(&Xmlparsetype) = &PyType_Type;
/* Create the module and add the functions */
- m = Py_InitModule3(MODULE_NAME, pyexpat_methods,
- pyexpat_module_documentation);
+ m = PyModule_Create(&pyexpatmodule);
if (m == NULL)
- return;
+ return NULL;
/* Add some symbolic constants to the module */
if (ErrorObject == NULL) {
ErrorObject = PyErr_NewException("xml.parsers.expat.ExpatError",
NULL, NULL);
if (ErrorObject == NULL)
- return;
+ return NULL;
}
Py_INCREF(ErrorObject);
PyModule_AddObject(m, "error", ErrorObject);
@@ -1844,7 +1855,7 @@ MODULE_INITFUNC(void)
Py_DECREF(modelmod_name);
if (errors_module == NULL || model_module == NULL)
/* Don't core dump later! */
- return;
+ return NULL;
#if XML_COMBINED_VERSION > 19505
{
@@ -1975,6 +1986,7 @@ MODULE_INITFUNC(void)
capi_object = PyCObject_FromVoidPtr(&capi, NULL);
if (capi_object)
PyModule_AddObject(m, "expat_CAPI", capi_object);
+ return m;
}
static void