FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.14] gh-85320: Use UTF-8 for IDLE configuration and breakpoint files (GH-152475) by miss-islington · Pull Request #152556 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) .rst  (1) .txt  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
5 changes: 5 additions & 0 deletions Lib/idlelib/News3.txt
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Released after 2025-10-07
=========================


gh-85320: IDLE now reads and writes its configuration files and the
breakpoints file using UTF-8 instead of the locale encoding.
Files with non-ASCII characters and non-UTF-8 encoding may need
to be opened in an editor and resaved with UTF-8 encoding.

gh-143774: Better explain the operation of Format / Format Paragraph.
Patch by Terry J. Reedy.

Expand Down
9 changes: 5 additions & 4 deletions Lib/idlelib/config.py
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
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ def GetOptionList(self, section):

def Load(self):
"Load the configuration file from disk."
if self.file:
self.read(self.file)
if self.file and os.path.exists(self.file):
with open(self.file, encoding='utf-8', errors='replace') as f:
self.read_file(f)

class IdleUserConfParser(IdleConfParser):
"""
Expand Down Expand Up @@ -133,10 +134,10 @@ def Save(self):
if fname and fname[0] != '#':
if not self.IsEmpty():
try:
cfgFile = open(fname, 'w')
cfgFile = open(fname, 'w', encoding='utf-8')
except OSError:
os.unlink(fname)
cfgFile = open(fname, 'w')
cfgFile = open(fname, 'w', encoding='utf-8')
with cfgFile:
self.write(cfgFile)
elif os.path.exists(self.file):
Expand Down
8 changes: 5 additions & 3 deletions Lib/idlelib/pyshell.py
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
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,13 @@ def store_file_breaks(self):
breaks = self.breakpoints
filename = self.io.filename
try:
with open(self.breakpointPath) as fp:
with open(self.breakpointPath,
encoding='utf-8', errors='replace') as fp:
lines = fp.readlines()
except OSError:
lines = []
try:
with open(self.breakpointPath, "w") as new_file:
with open(self.breakpointPath, "w", encoding='utf-8') as new_file:
for line in lines:
if not line.startswith(filename + '='):
new_file.write(line)
Expand All @@ -272,7 +273,8 @@ def restore_file_breaks(self):
if filename is None:
return
if os.path.isfile(self.breakpointPath):
with open(self.breakpointPath) as fp:
with open(self.breakpointPath,
encoding='utf-8', errors='replace') as fp:
lines = fp.readlines()
for line in lines:
if line.startswith(filename + '='):
Expand Down
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
IDLE now reads and writes its configuration files and the breakpoints file
using UTF-8 instead of the locale encoding. This keeps non-ASCII data (such
as non-ASCII paths) from being corrupted and makes the files portable between
environments.
Loading

Back | FazBrowse Home | New Git URL