diff options
| author | Stefan Krah <skrah@bytereef.org> | 2012-11-06 22:51:42 (GMT) |
|---|---|---|
| committer | Stefan Krah <skrah@bytereef.org> | 2012-11-06 22:51:42 (GMT) |
| commit | cd81709b9e60fe8c814a18d59186208c3ccbdacc (patch) | |
| tree | 12d445a7d856bf9c745cb9f7a4e5c337d71dc067 /Lib/test/support.py | |
| parent | e84226ac23c40ca7ab3920f877a4d380792ff7d1 (diff) | |
| parent | 8f049e5b5b360900a5f4d429040c8bfdc89d2fc6 (diff) | |
| download | cpython-cd81709b9e60fe8c814a18d59186208c3ccbdacc.zip cpython-cd81709b9e60fe8c814a18d59186208c3ccbdacc.tar.gz cpython-cd81709b9e60fe8c814a18d59186208c3ccbdacc.tar.bz2 | |
Merge.
Diffstat (limited to 'Lib/test/support.py')
| -rw-r--r-- | Lib/test/support.py | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/Lib/test/support.py b/Lib/test/support.py index 93b94d9..801ecf2 100644 --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -603,6 +603,32 @@ else: # module name. TESTFN = "{}_{}_tmp".format(TESTFN, os.getpid()) +# FS_NONASCII: non-ASCII character encodable by os.fsencode(), +# or None if there is no such character. +FS_NONASCII = None +for character in ( + # U+00E6 (Latin small letter AE): Encodable to cp1252, cp1254, cp1257, iso-8859-1 + '\u00E6', + # U+0141 (Latin capital letter L with stroke): Encodable to cp1250, cp1257 + '\u0141', + # U+041A (Cyrillic capital letter KA): Encodable to cp932, cp950, cp1251 + '\u041A', + # U+05D0 (Hebrew Letter Alef): Encodable to cp424, cp1255 + '\u05D0', + # U+06A9 (Arabic letter KEHEH): Encodable to cp1256 + '\u06A9', + # U+03A9 (Greek capital letter OMEGA): Encodable to cp932, cp950, cp1253 + '\u03A9', + # U+0E01 (Thai character KO KAI): Encodable to cp874 + '\u0E01', +): + try: + os.fsdecode(os.fsencode(character)) + except UnicodeError: + pass + else: + FS_NONASCII = character + break # TESTFN_UNICODE is a non-ascii filename TESTFN_UNICODE = TESTFN + "-\xe0\xf2\u0258\u0141\u011f" @@ -651,13 +677,22 @@ elif sys.platform != 'darwin': # decoded from the filesystem encoding (in strict mode). It can be None if we # cannot generate such filename. TESTFN_UNDECODABLE = None -for name in (b'abc\xff', b'\xe7w\xf0'): +# b'\xff' is not decodable by os.fsdecode() with code page 932. Windows +# accepts it to create a file or a directory, or don't accept to enter to +# such directory (when the bytes name is used). So test b'\xe7' first: it is +# not decodable from cp932. +for name in (b'\xe7w\xf0', b'abc\xff'): try: os.fsdecode(name) except UnicodeDecodeError: TESTFN_UNDECODABLE = name break +if FS_NONASCII: + TESTFN_NONASCII = TESTFN + '- ' + FS_NONASCII +else: + TESTFN_NONASCII = None + # Save the initial cwd SAVEDCWD = os.getcwd() |
