From 8752dfbd1f0c96ca09cdacabaf0d0f8c3895b6ce Mon Sep 17 00:00:00 2001 From: native-api Date: Thu, 6 Dec 2018 10:04:35 +0300 Subject: [PATCH] bpo-33709: test_ntpath and test_posixpath fail in Windows with ACP!=1252. (GH-7278) --- Lib/test/support/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index f90212cd7ec..05e8593f982 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -871,7 +871,11 @@ for character in ( '\u20AC', ): try: - os.fsdecode(os.fsencode(character)) + # If Python is set up to use the legacy 'mbcs' in Windows, + # 'replace' error mode is used, and encode() returns b'?' + # for characters missing in the ANSI codepage + if os.fsdecode(os.fsencode(character)) != character: + raise UnicodeError except UnicodeError: pass else: