gh-85604: Check IDLE theme colors at startup - #157620
serhiy-storchaka wants to merge 2 commits into
Conversation
An invalid color in a user highlight theme crashed the Settings dialog. Now it is ignored with a warning and the default color is used instead.
|
Tests / Windows / Build and test (Win32, switch-case) (pull_request)Failing after 18m |
There was a problem hiding this comment.
check_theme_color and its test should be in config.py, along with other config checking code, and invoked as part of the config checking process. The error messages should by added to the file_load_error_error message rather than sent to stderr to, usually, be lost.
pyshell itself would not need to be touched. EDIT I otherwise like this.
In the long run, all error messages after tkinter is successfully loaded should be sent to a new error message window (outwin or text window) that does not block continuation and that allows a user to save or print and that remains until a user deletes it.
|
When you're done making the requested changes, leave the comment: |
|
Done. The check is now I have made the requested changes; please review again |
|
Thanks for making the requested changes! @terryjreedy: please review the changes made to this pull request. |
A typo in a color in
~/.idlerc/config-highlight.cfg, such askeyword-foreground = bpo-00224, crashed the Settings dialog withTclError: unknown color name "bpo-00224"when the Highlights page painted its sample, so the theme could not be fixed from the GUI. Editor windows did not crash only becauseWidgetRedirectorsilently swallowsTclError, leaving the element uncolored without any warning.Colors can only be validated by Tk, so the check is done in
pyshell.main()right after the root is created and before any window uses the theme.check_theme_colors()validates every color of every user theme withwinfo_rgb(), prints a warning for each invalid one (in the style of #152747) and removes it from the loaded configuration, so thatGetThemeDict()supplies the default color instead. The user file is not modified until the settings are saved.Missing theme elements were already handled by
GetThemeDict().🤖 Generated with Claude Code