FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-66172: Don't let a corrupt config file prevent IDLE from starting by serhiy-storchaka · Pull Request #152764 · python/cpython · GitHub

Repository navigation

gh-66172: Don't let a corrupt config file prevent IDLE from starting - #152764

Merged
terryjreedy merged 2 commits into
python:mainfrom
serhiy-storchaka:gh-66172-corrupt-config
Sep 13, 2026
Merged

terryjreedy merged 2 commits into
python:mainfrom
serhiy-storchaka:gh-66172-corrupt-config

Conversation

serhiy-storchaka commented Jul 1, 2026 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

IDLE crashed at startup if a user configuration file could not be read — for example, a hand-edited config-extensions.cfg missing a section header (configparser.MissingSectionHeaderError), or a file that is not valid UTF-8. The file is read at import time, before any Tk root exists, which is why the error could not previously be shown in a message box (and printing to the console is invisible under pythonw).

Now the unreadable user file is renamed with a .bad suffix — so the user's file is preserved rather than overwritten or deleted when settings are next saved — IDLE continues with default settings, and main() shows a warning listing the affected files once the root is up. A corrupt shipped default file is left to surface as before, since that indicates a broken installation rather than user data.

This also removes the errors='replace' added to Load() in gh-85320: silently replacing undecodable bytes with U+FFFD mangled the values (and could be written back on the next save, making the corruption permanent). Letting the UnicodeDecodeError propagate and be handled the same way as a parse error is non-destructive and recoverable. Both changes target the same backport branches, so there is no version skew.

…rting

If a user configuration file cannot be read, rename it with a ".bad"
suffix, use default settings, and warn the user with a message box.

terryjreedy left a comment

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Nice fix. Approved either as is or with preferred changes.

Comment thread Lib/idlelib/idle_test/test_config.py Outdated
Comment on lines +315 to +316
def test_load_cfg_files_bad(self):
# gh-66172: an unparsable user file is renamed, not fatal, not lost.

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This better describes what gets tested.

Suggested change
def test_load_cfg_files_bad(self):
# gh-66172: an unparsable user file is renamed, not fatal, not lost.
def test_load_cfg_files_bad_format(self):
# gh-66172: rename an unparsable user file and save the exception.

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

done

Comment thread Lib/idlelib/pyshell.py
Comment thread Lib/idlelib/idle_test/test_config.py Outdated

bedevere-app Bot commented Sep 13, 2026

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

Say in the name of the test what it tests, and name the path after the
file it points to, not after the state of that file.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
terryjreedy dismissed their stale review September 13, 2026 19:42

Approve changes in response.

terryjreedy merged commit ae0d6cc into python:main Sep 13, 2026
53 of 55 checks passed

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR, and @terryjreedy for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

bedevere-app Bot commented Sep 13, 2026

Copy link
Copy Markdown

GH-157458 is a backport of this pull request to the 3.15 branch.

bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Sep 13, 2026

bedevere-app Bot commented Sep 13, 2026

Copy link
Copy Markdown

GH-157459 is a backport of this pull request to the 3.14 branch.

bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Sep 13, 2026

bedevere-app Bot commented Sep 13, 2026

Copy link
Copy Markdown

GH-157460 is a backport of this pull request to the 3.13 branch.

bedevere-app Bot removed the needs backport to 3.13 only security fixes label Sep 13, 2026
terryjreedy pushed a commit that referenced this pull request Sep 13, 2026
…arting (GH-152764) (#157460)

gh-66172: Don't let a corrupt config file prevent IDLE from starting (GH-152764)

If a user configuration file cannot be read, because of either bad unicode or configuration,
rename it with a ".bad" suffix, use default settings, and warn the user with a message box.
---------
(cherry picked from commit ae0d6cc)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
terryjreedy pushed a commit that referenced this pull request Sep 13, 2026
…arting (GH-152764) (#157459)

gh-66172: Don't let a corrupt config file prevent IDLE from starting (GH-152764)

If a user configuration file cannot be read, because of either bad unicode or configuration,
rename it with a ".bad" suffix, use default settings, and warn the user with a message box.
---------
(cherry picked from commit ae0d6cc)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
johnslavik pushed a commit to johnslavik/cpython that referenced this pull request Sep 14, 2026
…rting (python#152764)

If a user configuration file cannot be read, because of either bad unicode or configuration,
rename it with a ".bad" suffix, use default settings, and warn the user with a message box.
---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
terryjreedy pushed a commit that referenced this pull request Oct 9, 2026
…arting (GH-152764) (#157458)

gh-66172: Don't let a corrupt config file prevent IDLE from starting (GH-152764)

If a user configuration file cannot be read, because of either bad unicode or configuration,
rename it with a ".bad" suffix, use default settings, and warn the user with a message box.
---------
(cherry picked from commit ae0d6cc)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL