[issue35379] IDLE's close fails io is set to None on Mac

Terry J. Reedy report at bugs.python.org
Tue Sep 17 02:04:03 EDT 2019


Terry J. Reedy <tjreedy at udel.edu> added the comment:

By reading idlelib code, I determined that the error must arise from EditorWindow.close being called twice.  I confirmed this with a debug print.

EW.close is called from close_event, PyShell.close, and filelist.close_all_callback. For the AttributeError I see, msg352409, both calls come from PyShell.close (debug print) and at least the second from PseudoInputFile.close.  Since it does not happen in 3.7, in spite of code being identical, a 3.8 change in Python shutdown must be involved.

I am rather sure that a double close is also the problem on Raymond's mac, with at least the second coming from close_all_callback.  The latter is invoked by File => exit and exit() or quit().  It might be that I do not remember seeing the same traceback because I almost never exit that way.  On Windows, I often right click the IDLE taskbar icon and select 'close all windows'.  Or the binding of close_all_callback in macOSX might be involved.

As a practical matter, I am defining the bug to be fixed as printing an annoying and essentially useless traceback to a terminal used to start IDLE.  I could spend hours trying to prevent the 2nd call I see and even if I succeeded, there would still be the 2nd call I don't see, and the problem that prompted #17822.  Clean tk shutdown is tricky and there are other unresolved issues with IDLE tests.

PR 10564 uses the direct approach suggested by Tal.  It works for me however I shut down IDLE.

Setting a Boolean flag after the first call might be cleaner, but I don't know for sure that it would prevent what Raymond sees, and I want to get a fix into 3.7.5, and I am more sure that catching AttributeErrors will work for him as well.

----------
stage: patch review -> commit review
type:  -> behavior

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35379>
_______________________________________


More information about the Python-bugs-list mailing list