8000 gh-109508: Fix libregrtest formatting of getcwd() (#109537) · python/cpython@ef659b9 · GitHub
[go: up one dir, main page]

Skip to content

Commit ef659b9

Browse files
authored
gh-109508: Fix libregrtest formatting of getcwd() (#109537)
1 parent 412f5e8 commit ef659b9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Lib/test/libregrtest/utils.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,12 +556,21 @@ def adjust_rlimit_nofile():
556556

557557

558558
def display_header():
559+
encoding = sys.stdout.encoding
560+
559561
# Print basic platform information
560562
print("==", platform.python_implementation(), *sys.version.split())
561563
print("==", platform.platform(aliased=True),
562564
"%s-endian" % sys.byteorder)
563565
print("== Python build:", ' '.join(get_build_info()))
564-
print("== cwd:", os.getcwd())
566+
567+
cwd = os.getcwd()
568+
# gh-109508: support.os_helper.FS_NONASCII, used by get_work_dir(), cannot
569+
# be encoded to the filesystem encoding on purpose, escape non-encodable
570+
# characters with backslashreplace error handler.
571+
formatted_cwd = cwd.encode(encoding, "backslashreplace").decode(encoding)
572+
print("== cwd:", formatted_cwd)
573+
565574
cpu_count = os.cpu_count()
566575
if cpu_count:
567576
print("== CPU count:", cpu_count)

0 commit comments

Comments
 (0)
0