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/_tkinter.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'Modules/_tkinter.c') diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index 5002f4a001..40db86ef4f 100644 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -3009,8 +3009,20 @@ ins_string(PyObject *d, char *name, char *val) } +static struct PyModuleDef _tkintermodule = { + PyModuleDef_HEAD_INIT, + "_tkinter", + NULL, + -1, + moduleMethods, + NULL, + NULL, + NULL, + NULL +}; + PyMODINIT_FUNC -init_tkinter(void) +PyInit__tkinter(void) { PyObject *m, *d, *uexe, *cexe; @@ -3020,9 +3032,9 @@ init_tkinter(void) tcl_lock = PyThread_allocate_lock(); #endif - m = Py_InitModule("_tkinter", moduleMethods); + m = PyModule_Create(&_tkintermodule); if (m == NULL) - return; + return NULL; d = PyModule_GetDict(m); Tkinter_TclError = PyErr_NewException("_tkinter.TclError", NULL, NULL); @@ -3076,8 +3088,10 @@ init_tkinter(void) Py_DECREF(uexe); } - if (PyErr_Occurred()) - return; + if (PyErr_Occurred()) { + Py_DECREF(m); + return NULL; + } #if 0 /* This was not a good idea; through bindings, @@ -3085,5 +3099,5 @@ init_tkinter(void) interpreter and thread state have already been destroyed! */ Py_AtExit(Tcl_Finalize); #endif - + return m; } -- cgit v1.2.1