Commit cd246992 authored by Martin v. Löwis's avatar Martin v. Löwis

Try a different filename if the Latin-1 file name cannot

be represented in the file system. Fixes #989338.
parent 4de9374b
......@@ -14,6 +14,23 @@ except (UnicodeError, TypeError):
# cannot be encoded in the file system encoding.
raise TestSkipped("No Unicode filesystem semantics on this platform.")
if TESTFN_ENCODED.decode(TESTFN_ENCODING) != TESTFN_UNICODE:
# The file system encoding does not support Latin-1
# (which test_support assumes), so try the file system
# encoding instead.
import sys
try:
TESTFN_UNICODE = unicode("@test-\xe0\xf2", sys.getfilesystemencoding())
TESTFN_ENCODED = TESTFN_UNICODE.encode(TESTFN_ENCODING)
if '?' in TESTFN_ENCODED:
# MBCS will not report the error properly
raise UnicodeError, "mbcs encoding problem"
except (UnicodeError, TypeError):
raise TestSkipped("Cannot find a suiteable filename.")
if TESTFN_ENCODED.decode(TESTFN_ENCODING) != TESTFN_UNICODE:
raise TestSkipped("Cannot find a suitable filename.")
def remove_if_exists(filename):
if os.path.exists(filename):
os.unlink(filename)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment