Repository navigation
IDLE fails to start or raises when an editor window's file does not exist #153480
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Jul 10, 2026 - addedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
on Jul 10, 2026 I choose the IDLE Issues topic "File save" as the closest because this is not about editing but about interaction with the external filesystem. I suspect that there could also be problems if Shell or an output window have been 'saved as'.
Reacted by tonghuaroot (童话)- addedtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
on Aug 7, 2026 This is worse than a traceback on FocusIn: the same
last_mtime()runs fromset_saved(True)insideEditorWindow.__init__, so opening a file that does not exist yet —python -m idlelib new.py, the usual way to start a new script — aborts IDLE at startup withFileNotFoundError. Regression from gh-94523; affects 3.13.15, 3.14.7, 3.15.0b1 and main.Traceback:
pyshell.main→filelist.open→EditorWindow.__init__(editor.py:242) →iomenu.set_filename→set_saved→editor.set_saved(1033) →last_mtime(1121) →os.path.getmtime.Proposed behavior:
last_mtime()returnsNonewhen there is no file or it cannot be stat'ed (not0, which is a valid mtime on filesystems without timestamps). If a file that was there is gone on FocusIn, ask Close / Save As / Ignore (default Save As); Ignore marks the window unsaved and resets the stored mtime toNoneso the question is asked once. This is an approximate plan; details can be changed later. See the review on #153481.- changed the title
[-]IDLE crashes when a file open in the editor is deleted or renamed externally[/-][+]IDLE fails to start or raises when an editor window's file does not exist[/+]on Sep 15, 2026 - added3.14bugs and security fixesbugs and security fixes3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixes
on Sep 15, 2026 - added 3 commits that reference this issue
on Sep 17, 2026
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Bug report
Bug description:
IDLE raises an uncaught traceback when a file that is open in the editor is deleted or renamed by another program and the IDLE window is then refocused.
EditorWindow.focus_in_eventruns on every<FocusIn>event and callsEditorWindow.last_mtime, which callsos.path.getmtime(self.io.filename)with no error handling. When the open file has been removed or renamed,getmtimeraisesFileNotFoundError, which escapes the Tk event handler and breaks the modified-on-disk reload check.Reproduction
Open a file in the IDLE editor, delete or rename it in another program, then click back into the IDLE window. A traceback like this reaches the console and the reload check stops working:
The same call reproduced without a GUI:
Suggested fix
Guard
os.path.getmtimeinlast_mtimewithtry/except OSErrorand return the last known mtime, sofocus_in_eventsees no change and does not prompt to reload a file that is gone.CPython versions tested on:
3.16, CPython main branch
Operating systems tested on:
macOS
Linked PRs