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/_elementtree.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/_elementtree.c')
-rw-r--r-- | Modules/_elementtree.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c index 0c8bf2a..099df7b 100644 --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -2549,8 +2549,21 @@ static PyMethodDef _functions[] = { {NULL, NULL} }; + +static struct PyModuleDef _elementtreemodule = { + PyModuleDef_HEAD_INIT, + "_elementtree", + NULL, + -1, + _functions, + NULL, + NULL, + NULL, + NULL +}; + PyMODINIT_FUNC -init_elementtree(void) +PyInit__elementtree(void) { PyObject* m; PyObject* g; @@ -2565,15 +2578,21 @@ init_elementtree(void) Py_TYPE(&XMLParser_Type) = &PyType_Type; #endif - m = Py_InitModule("_elementtree", _functions); + m = PyModule_Create(&_elementtreemodule); if (!m) - return; + return NULL; + + /* The code below requires that the module gets already added + to sys.modules. */ + PyDict_SetItemString(PyImport_GetModuleDict(), + _elementtreemodule.m_name, + m); /* python glue code */ g = PyDict_New(); if (!g) - return; + return NULL; PyDict_SetItemString(g, "__builtins__", PyEval_GetBuiltins()); @@ -2748,5 +2767,6 @@ init_elementtree(void) else expat_capi = NULL; #endif + return m; } |