From: Victor Stinner Date: Wed, 29 Sep 2010 16:59:18 +0000 (+0000) Subject: Use os.fsencode() to support surrogates X-Git-Tag: v3.2a3~94 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=16004ace5bb9b566b68e9016926e88d78edbbf50;p=thirdparty%2FPython%2Fcpython.git Use os.fsencode() to support surrogates --- diff --git a/Demo/zlib/minigzip.py b/Demo/zlib/minigzip.py index 52e81b993f92..b57de7348ec8 100755 --- a/Demo/zlib/minigzip.py +++ b/Demo/zlib/minigzip.py @@ -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'') diff --git a/Lib/posixpath.py b/Lib/posixpath.py index 37da71e615e5..2d68b7322bd2 100644 --- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -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 = '/'