Use os.fsencode() to support surrogates

This commit is contained in:
Victor Stinner 2010-09-29 16:59:18 +00:00
parent c39211f51e
commit 16004ace5b
2 changed files with 2 additions and 2 deletions

View File

@ -31,7 +31,7 @@ def compress(filename, input, output):
write32(output, mtime)
output.write(b'\002') # ... slowest compression alg. ...
output.write(b'\377') # ... OS (=unknown) ...
bfilename = filename.encode(sys.getfilesystemencoding())
bfilename = os.fsencode(filename)
output.write(bfilename + b'\000') # ... original filename ...
crcval = zlib.crc32(b'')

View File

@ -262,7 +262,7 @@ def expanduser(path):
return path
userhome = pwent.pw_dir
if isinstance(path, bytes):
userhome = userhome.encode(sys.getfilesystemencoding())
userhome = os.fsencode(userhome)
root = b'/'
else:
root = '/'