Skip to content

gh-153477: Fix IDLE startup crash on a corrupt user config file#153478

Open
tonghuaroot wants to merge 2 commits into
python:mainfrom
tonghuaroot:idlelib-config-corrupt-load
Open

gh-153477: Fix IDLE startup crash on a corrupt user config file#153478
tonghuaroot wants to merge 2 commits into
python:mainfrom
tonghuaroot:idlelib-config-corrupt-load

Conversation

@tonghuaroot

@tonghuaroot tonghuaroot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

IdleConfParser.Load called configparser's read_file with no error handling, so a corrupt or partially written user configuration file (for example one left behind by an interrupted Save) raised a configparser.Error such as MissingSectionHeaderError and aborted IDLE startup. This contradicts the graceful-degradation behavior documented in the config.py module docstring.

Load now catches configparser.Error, warns to stderr, and falls back to the default configuration. The regression test writes a headerless config file and checks that Load warns and leaves the parser empty instead of raising.

IdleConfParser.Load raised the configparser exception on a corrupt or
partially written user configuration file, which aborted IDLE startup.
Catch it, warn, and fall back to the default configuration, matching the
module's documented graceful-degradation behavior.
Comment thread Lib/idlelib/idle_test/test_config.py Outdated
self.assertEqual(parser.GetOptionList('Foo Bar'), ['foo'])

def test_load_invalid_file(self):
# gh-000000: a corrupt config file must warn and fall back to

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.

Suggested change
# gh-000000: a corrupt config file must warn and fall back to
# gh-153478: a corrupt config file must warn and fall back to

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, fixed in 0a94b48. Used the issue number gh-153477 to match the commit subject and the NEWS entry.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants