summaryrefslogtreecommitdiffstats
path: root/Python/_warnings.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 /Python/_warnings.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 'Python/_warnings.c')
-rw-r--r--Python/_warnings.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/Python/_warnings.c b/Python/_warnings.c
index 8ccd4bb..6cc493b 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -868,33 +868,46 @@ init_filters(void)
return filters;
}
+static struct PyModuleDef warningsmodule = {
+ PyModuleDef_HEAD_INIT,
+ MODULE_NAME,
+ warnings__doc__,
+ 0,
+ warnings_functions,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
PyMODINIT_FUNC
_PyWarnings_Init(void)
{
PyObject *m, *default_action;
- m = Py_InitModule3(MODULE_NAME, warnings_functions, warnings__doc__);
+ m = PyModule_Create(&warningsmodule);
if (m == NULL)
- return;
+ return NULL;
_filters = init_filters();
if (_filters == NULL)
- return;
+ return NULL;
Py_INCREF(_filters);
if (PyModule_AddObject(m, "filters", _filters) < 0)
- return;
+ return NULL;
_once_registry = PyDict_New();
if (_once_registry == NULL)
- return;
+ return NULL;
Py_INCREF(_once_registry);
if (PyModule_AddObject(m, "once_registry", _once_registry) < 0)
- return;
+ return NULL;
default_action = PyUnicode_InternFromString("default");
if (default_action == NULL)
- return;
+ return NULL;
if (PyModule_AddObject(m, DEFAULT_ACTION_NAME, default_action) < 0)
- return;
+ return NULL;
+ return m;
}