diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2008-06-11 05:26:20 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2008-06-11 05:26:20 (GMT) |
commit | 1a21451b1d73b65af949193208372e86bf308411 (patch) | |
tree | 8e98d7be9e249b011ae9380479656e5284ec0234 /Modules/_tkinter.c | |
parent | cdf94635d7e364f9ce1905bafa5b540f4d16147c (diff) | |
download | cpython-1a21451b1d73b65af949193208372e86bf308411.zip cpython-1a21451b1d73b65af949193208372e86bf308411.tar.gz cpython-1a21451b1d73b65af949193208372e86bf308411.tar.bz2 |
Implement PEP 3121: new module initialization and finalization API.
Diffstat (limited to 'Modules/_tkinter.c')
-rw-r--r-- | Modules/_tkinter.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index 5002f4a..40db86e 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 <Destroy> bindings, @@ -3085,5 +3099,5 @@ init_tkinter(void) interpreter and thread state have already been destroyed! */ Py_AtExit(Tcl_Finalize); #endif - + return m; } |