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/_sre.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/_sre.c')
-rw-r--r-- | Modules/_sre.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/Modules/_sre.c b/Modules/_sre.c index 22aff76..ab8adda 100644 --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -3387,7 +3387,19 @@ static PyMethodDef _functions[] = { {NULL, NULL} }; -PyMODINIT_FUNC init_sre(void) +static struct PyModuleDef sremodule = { + PyModuleDef_HEAD_INIT, + "_" SRE_MODULE, + NULL, + -1, + _functions, + NULL, + NULL, + NULL, + NULL +}; + +PyMODINIT_FUNC PyInit__sre(void) { PyObject* m; PyObject* d; @@ -3395,15 +3407,15 @@ PyMODINIT_FUNC init_sre(void) /* Initialize object types */ if (PyType_Ready(&Pattern_Type) < 0) - return; + return NULL; if (PyType_Ready(&Match_Type) < 0) - return; + return NULL; if (PyType_Ready(&Scanner_Type) < 0) - return; + return NULL; - m = Py_InitModule("_" SRE_MODULE, _functions); + m = PyModule_Create(&sremodule); if (m == NULL) - return; + return NULL; d = PyModule_GetDict(m); x = PyLong_FromLong(SRE_MAGIC); @@ -3423,6 +3435,7 @@ PyMODINIT_FUNC init_sre(void) PyDict_SetItemString(d, "copyright", x); Py_DECREF(x); } + return m; } #endif /* !defined(SRE_RECURSIVE) */ |