diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2012-10-30 02:17:38 +0100 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2012-10-30 02:17:38 +0100 |
commit | 292c835548df618983043b9698d0dc8c34adea12 (patch) | |
tree | 11ae17b994b6eaaaf5625d05839ad16af03443f9 /Lib/test/support.py | |
parent | 76df43de30f40b5cc1de9d36a5a083dd8bd8cb27 (diff) | |
download | cpython-git-292c835548df618983043b9698d0dc8c34adea12.tar.gz |
Issue #15478: Raising an OSError doesn't decode or encode the filename anymore
Pass the original filename argument to OSError constructor, instead of trying
to encode it to or decode it from the filesystem encoding. This change avoids
an additionnal UnicodeDecodeError on Windows if the filename cannot be decoded
from the filesystem encoding (ANSI code page).
Diffstat (limited to 'Lib/test/support.py')
-rw-r--r-- | Lib/test/support.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/support.py b/Lib/test/support.py index c5640e0a08..1717c0690b 100644 --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -647,6 +647,17 @@ elif sys.platform != 'darwin': # the byte 0xff. Skip some unicode filename tests. pass +# TESTFN_UNDECODABLE is a filename (bytes type) that should *not* be able to be +# 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'): + try: + os.fsdecode(name) + except UnicodeDecodeErorr: + TESTFN_UNDECODABLE = name + break + # Save the initial cwd SAVEDCWD = os.getcwd() |