]> granicus.if.org Git - python/commitdiff
Use os.fsencode() to support surrogates
authorVictor Stinner <victor.stinner@haypocalc.com>
Wed, 29 Sep 2010 16:59:18 +0000 (16:59 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Wed, 29 Sep 2010 16:59:18 +0000 (16:59 +0000)
Demo/zlib/minigzip.py
Lib/posixpath.py

index 52e81b993f92de3f188174ace1ddae75bfbd5966..b57de7348ec86be0178ef1dcc5a548326152745d 100755 (executable)
@@ -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'')
index 37da71e615e53c12db9126ee049174621356ffa9..2d68b7322bd2d58340360b6b333019ef4ca22bc3 100644 (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 = '/'