Skip to content

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

Open
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-66172-corrupt-config
Open

gh-66172: Don't let a corrupt config file prevent IDLE from starting#152764
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-66172-corrupt-config

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jul 1, 2026

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.

@serhiy-storchaka serhiy-storchaka added the needs backport to 3.13 bugs and security fixes label Jul 1, 2026
@serhiy-storchaka serhiy-storchaka added needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jul 1, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant