Mercurial > cpython-lru_cache-weakref
diff Python/_warnings.c @ 47580:94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Wed, 11 Jun 2008 05:26:20 +0000 |
| parents | b630729571e6 |
| children | 605ab6f92838 |
line wrap: on
line diff
--- a/Python/_warnings.c Wed Jun 11 03:41:00 2008 +0000 +++ b/Python/_warnings.c Wed Jun 11 05:26:20 2008 +0000 @@ -868,33 +868,46 @@ 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; }
