gh-66172: Don't let a corrupt config file prevent IDLE from starting#152764
Open
serhiy-storchaka wants to merge 1 commit into
Open
gh-66172: Don't let a corrupt config file prevent IDLE from starting#152764serhiy-storchaka wants to merge 1 commit into
serhiy-storchaka wants to merge 1 commit into
Conversation
…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.
23f16c7 to
8e989e9
Compare
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
IDLE crashed at startup if a user configuration file could not be read — for example, a hand-edited
config-extensions.cfgmissing 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 underpythonw).Now the unreadable user file is renamed with a
.badsuffix — so the user's file is preserved rather than overwritten or deleted when settings are next saved — IDLE continues with default settings, andmain()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 toLoad()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 theUnicodeDecodeErrorpropagate 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.