From 1a21451b1d73b65af949193208372e86bf308411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Wed, 11 Jun 2008 05:26:20 +0000 Subject: Implement PEP 3121: new module initialization and finalization API. --- Python/_warnings.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'Python/_warnings.c') diff --git a/Python/_warnings.c b/Python/_warnings.c index 8ccd4bb54a..6cc493bea5 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; } -- cgit v1.2.1