Skip to content

Commit 8752dfb

Browse files
native-apiserhiy-storchaka
authored andcommitted
bpo-33709: test_ntpath and test_posixpath fail in Windows with ACP!=1252. (GH-7278)
1 parent 6ea9d54 commit 8752dfb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Lib/test/support/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,11 @@ def dec(*args, **kwargs):
871871
'\u20AC',
872872
):
873873
try:
874-
os.fsdecode(os.fsencode(character))
874+
# If Python is set up to use the legacy 'mbcs' in Windows,
875+
# 'replace' error mode is used, and encode() returns b'?'
876+
# for characters missing in the ANSI codepage
877+
if os.fsdecode(os.fsencode(character)) != character:
878+
raise UnicodeError
875879
except UnicodeError:
876880
pass
877881
else:

0 commit comments

Comments
 (0)