Terry J. Reedy <tjre...@udel.edu> added the comment:
The #if 0 was added by Guido in 43ff8683fe68424b9c179ee4970bb865e11036d6 in 1998, before the tcl/tk clip fix for Windows. * Temporarily get rid of the registration of Tcl_Finalize() as a low-level Python exit handler. This can attempt to call Python code at a point that the interpreter and thread state have already been destroyed, causing a Bus Error. Given the intended use of Py_AtExit(), I'm not convinced that it's a good idea to call it earlier during Python's finalization sequence... (Although this is the only use for it in the entire distribution.) The code has a comment that was part of a multifile svn merge, so author unknown. /* This was not a good idea; through <Destroy> bindings, Tcl_Finalize() may invoke Python code but at that point the interpreter and thread state have already been destroyed! */ Calling Tcl_Finalize() within Tk.destroy avoids this as .destroy is called while python is running, either explicitly or when the associated window is closed. However, it is possible to have more than 1 Tk instance, either accidentally or on purpose*, each with its own .tk, which I presume is the 'associated tcl interpreter' instance. So Tk.destroy may be called more than once and each call must not disable other Tk instances. To test: Create 2 roots and two Tk windows, destroy 1. Does the other window disappear? Does root2.withdraw raise? Does adding widgets raise? If yes, we would either need to count working Tk instances or try calling less shutdown stuff. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40452> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com