瀏覽代碼

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

Gary van der Merwe 10 年之前
父節點
當前提交
b514d8893c
共有 1 個文件被更改,包括 6 次插入0 次删除
  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