Visitar URL original
[3.15] gh-153480: Stop IDLE crashing when a file open in the editor is deleted (GH-153481) by miss-islington · Pull Request #158264 · python/cpython · GitHub
Skip to content

[3.15] gh-153480: Stop IDLE crashing when a file open in the editor is deleted (GH-153481) - #158264

Open
miss-islington wants to merge 1 commit into
python:3.15from
miss-islington:backport-6af40a6-3.15
Open

miss-islington wants to merge 1 commit into
python:3.15from
miss-islington:backport-6af40a6-3.15

Conversation

@miss-islington

@miss-islington miss-islington commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

EditorWindow.focus_in_event calls last_mtime on every event,
which passed the open file path to os.path.getmtime with no guard. When
another program deleted or renamed the file, refocusing the IDLE window
let a FileNotFoundError escape the Tk event handler. last_mtime now
returns the last known mtime when the path is inaccessible, so refocusing
no longer raises and does not prompt to reload a file that is gone.
See PR discussion for more.


(cherry picked from commit 6af40a6)

Co-authored-by: tonghuaroot (童话) tonghuaroot@gmail.com
Co-authored-by: Serhiy Storchaka storchaka@gmail.com

… deleted (pythonGH-153481)

EditorWindow.focus_in_event calls last_mtime on every <FocusIn> event,
which passed the open file path to os.path.getmtime with no guard. When
another program deleted or renamed the file, refocusing the IDLE window
let a FileNotFoundError escape the Tk event handler. last_mtime now
returns the last known mtime when the path is inaccessible, so refocusing
no longer raises and does not prompt to reload a file that is gone.
See PR discussion for more.

---------
(cherry picked from commit 6af40a6)

Co-authored-by: tonghuaroot (童话) <tonghuaroot@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
import os
import tempfile
import types
import unittest

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing: from unittest import mock

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is #23 of 23 3.15 backports waiting to be merged into 3.15. This is being tested with 3.15 missing the previous 21 patches that were in main when this was merged into main. I strongly suspect that one of them added the unittest import. We should wait until those 21 are merged before doing anything. If we add it here, it would have to be in exactly the right place, if such is possible, to avoid a merge conflict that would otherwise not happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants