Skip to content

gh-85320: Use UTF-8 for IDLE configuration and breakpoint files#152475

Merged
serhiy-storchaka merged 2 commits into
python:mainfrom
serhiy-storchaka:idle-config-utf8
Jun 29, 2026
Merged

gh-85320: Use UTF-8 for IDLE configuration and breakpoint files#152475
serhiy-storchaka merged 2 commits into
python:mainfrom
serhiy-storchaka:idle-config-utf8

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jun 28, 2026

Copy link
Copy Markdown
Member

IDLE opened its configuration files (.idlerc/config-*.cfg) and the breakpoints file without an explicit encoding, so they used the locale encoding. Non-ASCII data — such as non-ASCII paths in the breakpoints file or help-source URLs in the config — could be corrupted, and the files were not portable between environments.

Read them as UTF-8 with errors='replace' and write them as UTF-8, matching the long-standing treatment of recent-files.lst.

Since UTF-8 mode is the default from 3.15 (PEP 686), this is mostly a no-op on current main except under -X utf8=0; the behavioral fix matters on the 3.13 and 3.14 backports, where the locale encoding is still used.

Reading with errors='replace' instead of the locale codec also means a config file written in a different encoding no longer raises UnicodeDecodeError and crashes IDLE on startup; it is decoded lossily instead. This also fixes gh-84615.

They were read and written using the locale encoding, which could corrupt
non-ASCII paths and made them non-portable.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@serhiy-storchaka serhiy-storchaka added 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 labels Jun 28, 2026
@terryjreedy

Copy link
Copy Markdown
Member

I intend to check later today that the change creates no problems on an existing Window installation with both config and breakpoint files.

@terryjreedy 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.

My quick check of reading, editing, saving and using both files showed no problems.

Comment thread Lib/idlelib/News3.txt
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) June 29, 2026 07:48
@serhiy-storchaka serhiy-storchaka merged commit f6e904e into python:main Jun 29, 2026
51 checks passed
@miss-islington-app

Copy link
Copy Markdown

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

@bedevere-app

bedevere-app Bot commented Jun 29, 2026

Copy link
Copy Markdown

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jun 29, 2026
@bedevere-app

bedevere-app Bot commented Jun 29, 2026

Copy link
Copy Markdown

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jun 29, 2026
@bedevere-app

bedevere-app Bot commented Jun 29, 2026

Copy link
Copy Markdown

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Jun 29, 2026
serhiy-storchaka added a commit that referenced this pull request Jun 29, 2026
GH-152475) (GH-152557)

They were read and written using the locale encoding, which could corrupt
non-ASCII paths and made them non-portable.
(cherry picked from commit f6e904e)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
serhiy-storchaka added a commit that referenced this pull request Jun 29, 2026
GH-152475) (GH-152556)

They were read and written using the locale encoding, which could corrupt
non-ASCII paths and made them non-portable.
(cherry picked from commit f6e904e)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
serhiy-storchaka added a commit that referenced this pull request Jun 29, 2026
GH-152475) (GH-152555)

They were read and written using the locale encoding, which could corrupt
non-ASCII paths and made them non-portable.
(cherry picked from commit f6e904e)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
@serhiy-storchaka serhiy-storchaka deleted the idle-config-utf8 branch June 29, 2026 08:52
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.

IDLE should catch user config file UnicodeDecodeError

2 participants