mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
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).
This commit is contained in:
parent
76df43de30
commit
292c835548
5 changed files with 199 additions and 108 deletions
|
@ -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()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue