https://github.com/python/cpython/commit/ddcb61ec4c068b22ae2f4e1e8847841573a5f3d4
commit: ddcb61ec4c068b22ae2f4e1e8847841573a5f3d4
branch: 3.13
author: Serhiy Storchaka <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-07-26T19:07:44Z
summary:

[3.13] gh-154592: Fix test_peg_generator in non-UTF-8 locales with a non-ASCII 
work dir (GH-154593) (GH-154603)

(cherry picked from commit da46947470013f3e36221bfc6b73c10725a95c8b)

Co-authored-by: Claude Opus 4.8 <[email protected]>

files:
M Lib/test/test_peg_generator/test_c_parser.py

diff --git a/Lib/test/test_peg_generator/test_c_parser.py 
b/Lib/test/test_peg_generator/test_c_parser.py
index 1095e7303c188f6..2e9cef99dd355c7 100644
--- a/Lib/test/test_peg_generator/test_c_parser.py
+++ b/Lib/test/test_peg_generator/test_c_parser.py
@@ -100,10 +100,16 @@ def setUpClass(cls):
 
         with contextlib.ExitStack() as stack:
             python_exe = 
stack.enter_context(support.setup_venv_with_pip_setuptools("venv"))
-            sitepackages = subprocess.check_output(
-                [python_exe, "-c", "import sysconfig; 
print(sysconfig.get_path('platlib'))"],
-                text=True,
-            ).strip()
+
+            def get_sysconfig_path(name):
+                # Force UTF-8 to emit the non-ASCII venv path in any locale.
+                return subprocess.check_output(
+                    [python_exe, "-X", "utf8", "-c",
+                     f"import sysconfig; print(sysconfig.get_path({name!r}))"],
+                    encoding="utf-8",
+                ).strip()
+
+            sitepackages = get_sysconfig_path("platlib")
             stack.enter_context(import_helper.DirsOnSysPath(sitepackages))
             cls.addClassCleanup(stack.pop_all().close)
 

_______________________________________________
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