https://github.com/python/cpython/commit/f5725af706ce62d0d5ec34e63aa782f6c05ddf34
commit: f5725af706ce62d0d5ec34e63aa782f6c05ddf34
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: terryjreedy <[email protected]>
date: 2026-09-20T21:28:29Z
summary:

[3.13] gh-153319: Read turtledemo scripts as UTF-8 (GH-153321) (#157874)

Stop using locale default encoding. All stdlib .py files (except for testing) 
are utf-8 encoded.

---------
(cherry picked from commit de0d9763682b414c028b3443aeab60fe2daec645)

Co-authored-by: tonghuaroot (童话) <[email protected]>
Co-authored-by: Serhiy Storchaka <[email protected]>
Co-authored-by: Terry Jan Reedy <[email protected]>

files:
A Misc/NEWS.d/next/Library/2026-07-08-19-40-00.gh-issue-153319.Qk7bE2.rst
M Lib/turtledemo/__main__.py

diff --git a/Lib/turtledemo/__main__.py b/Lib/turtledemo/__main__.py
index 967ccb0f15308a9..7293859f7b1d50a 100755
--- a/Lib/turtledemo/__main__.py
+++ b/Lib/turtledemo/__main__.py
@@ -335,7 +335,7 @@ def loadfile(self, filename):
         modname = 'turtledemo.' + filename
         __import__(modname)
         self.module = sys.modules[modname]
-        with open(self.module.__file__, 'r') as f:
+        with open(self.module.__file__, encoding='utf-8') as f:
             chars = f.read()
         self.text.delete("1.0", "end")
         self.text.insert("1.0", chars)
diff --git 
a/Misc/NEWS.d/next/Library/2026-07-08-19-40-00.gh-issue-153319.Qk7bE2.rst 
b/Misc/NEWS.d/next/Library/2026-07-08-19-40-00.gh-issue-153319.Qk7bE2.rst
new file mode 100644
index 000000000000000..95f8e2fb7f4f8be
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2026-07-08-19-40-00.gh-issue-153319.Qk7bE2.rst
@@ -0,0 +1,2 @@
+The :mod:`turtledemo` viewer now reads each demo script as UTF-8 instead of
+the locale encoding.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to