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. --- Modules/_collectionsmodule.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'Modules/_collectionsmodule.c') diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index db07537de1..02ffb561dc 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -1348,31 +1348,44 @@ PyDoc_STRVAR(module_doc, - defaultdict: dict subclass with a default value factory\n\ "); + +static struct PyModuleDef _collectionsmodule = { + PyModuleDef_HEAD_INIT, + "_collections", + module_doc, + -1, + NULL, + NULL, + NULL, + NULL, + NULL +}; + PyMODINIT_FUNC -init_collections(void) +PyInit__collections(void) { PyObject *m; - m = Py_InitModule3("_collections", NULL, module_doc); + m = PyModule_Create(&_collectionsmodule); if (m == NULL) - return; + return NULL; if (PyType_Ready(&deque_type) < 0) - return; + return NULL; Py_INCREF(&deque_type); PyModule_AddObject(m, "deque", (PyObject *)&deque_type); defdict_type.tp_base = &PyDict_Type; if (PyType_Ready(&defdict_type) < 0) - return; + return NULL; Py_INCREF(&defdict_type); PyModule_AddObject(m, "defaultdict", (PyObject *)&defdict_type); if (PyType_Ready(&dequeiter_type) < 0) - return; + return NULL; if (PyType_Ready(&dequereviter_type) < 0) - return; + return NULL; - return; + return m; } -- cgit v1.2.1