https://github.com/python/cpython/commit/f4fbacf64a094e4ae8a8052b28331a3eee178035
commit: f4fbacf64a094e4ae8a8052b28331a3eee178035
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2026-11-14T00:31:19Z
summary:
Enhance encodings in regrtest header (#161959)
If the UTF-8 mode is disabled and/or if PYTHONCOERCECLOCALE
environment variable is set to "0": mention it in the "== encodings"
regrtest header.
If the locale encoding and the filesystem encoding are equal,
log "locale=FS=<encoding>" to have a shorter output.
On Windows, log ANSI and OEM code pages.
files:
M Lib/test/libregrtest/utils.py
diff --git a/Lib/test/libregrtest/utils.py b/Lib/test/libregrtest/utils.py
index 41a798c71089f9..28e6d904fa28aa 100644
--- a/Lib/test/libregrtest/utils.py
+++ b/Lib/test/libregrtest/utils.py
@@ -665,8 +665,32 @@ def display_header(use_resources: dict[str, str | None],
if process_cpu_count and process_cpu_count != cpu_count:
cpu_count = f"{process_cpu_count} (process) / {cpu_count} (system)"
print("== CPU count:", cpu_count)
- print("== encodings: locale=%s FS=%s"
- % (locale.getencoding(), sys.getfilesystemencoding()))
+
+ encodings = []
+ if _winapi is not None:
+ # Log ANSI and OEM code pages
+ ansi = f'cp{_winapi.GetACP()}'
+ oem = f'cp{_winapi.GetOEMCP()}'
+ if ansi == oem:
+ encodings.append(f'ansi=oem={ansi}')
+ else:
+ encodings.append(f'ansi={ansi}')
+ encodings.append(f'oem={oem}')
+ encodings.append(f'FS={sys.getfilesystemencoding()}')
+ else:
+ locale_encoding = locale.getencoding() # nl_langinfo(CODESET)
+ fs_encoding = sys.getfilesystemencoding() # normalized name
+ if locale_encoding.lower() == fs_encoding.lower():
+ encodings.append(f'locale=FS={fs_encoding}')
+ else:
+ encodings.append(f'locale={locale_encoding}')
+ encodings.append(f'FS={fs_encoding}')
+ if not sys.flags.utf8_mode:
+ encodings.append('utf8=0')
+ if (not sys.flags.ignore_environment
+ and os.environ.get('PYTHONCOERCECLOCALE') == '0'):
+ encodings.append('coerce=0')
+ print(f"== encodings: {' '.join(encodings)}")
if use_resources:
text = format_resources(use_resources)
_______________________________________________
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]