diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2004-11-07 19:57:35 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2004-11-07 19:57:35 (GMT) |
commit | cd246992567ac55dadb3503467a73f70ef30a04a (patch) | |
tree | 3f7bf788384dce8230347344a0099597172055b4 /Lib/test/test_unicode_file.py | |
parent | 4de9374b0e8fc3ddae4b2069cdfbdd9950d95599 (diff) | |
download | cpython-cd246992567ac55dadb3503467a73f70ef30a04a.zip cpython-cd246992567ac55dadb3503467a73f70ef30a04a.tar.gz cpython-cd246992567ac55dadb3503467a73f70ef30a04a.tar.bz2 |
Try a different filename if the Latin-1 file name cannot
be represented in the file system. Fixes #989338.
Diffstat (limited to 'Lib/test/test_unicode_file.py')
-rw-r--r-- | Lib/test/test_unicode_file.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_unicode_file.py b/Lib/test/test_unicode_file.py index e3ab5e6..87f73ac 100644 --- a/Lib/test/test_unicode_file.py +++ b/Lib/test/test_unicode_file.py @@ -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) |