Procházet zdrojové kódy

Fix index.blob_from_path_and_stat on pypy with paths with non ascii unicode.

Gary van der Merwe před 10 roky
rodič
revize
b514d8893c
1 změnil soubory, kde provedl 6 přidání a 0 odebrání
  1. 6 0
      dulwich/index.py

+ 6 - 0
dulwich/index.py

@@ -21,6 +21,7 @@
 import collections
 import errno
 import os
+import platform
 import stat
 import struct
 import sys
@@ -513,6 +514,11 @@ def blob_from_path_and_stat(path, st):
         with open(path, 'rb') as f:
             blob.data = f.read()
     else:
+        if platform.python_implementation() == 'PyPy':
+            # os.readlink on pypy seems to require bytes
+            # TODO: GaryvdM: test on other pypy configurations,
+            # e.g. windows, pypy3.
+            path = path.encode(sys.getfilesystemencoding())
         blob.data = os.readlink(path).encode(sys.getfilesystemencoding())
     return blob