File tree 3 files changed +13
-4
lines changed
3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -308,6 +308,6 @@ def register_surrogateescape():
308
308
309
309
310
310
try :
311
- "hello " .decode (defenc , "surrogateescape" )
311
+ b"100644 \x9f \0 aaa " .decode (defenc , "surrogateescape" )
312
312
except :
313
313
register_surrogateescape ()
Original file line number Diff line number Diff line change 2
2
from stat import S_ISDIR
3
3
from git .compat import (
4
4
byte_ord ,
5
+ safe_decode ,
5
6
defenc ,
6
7
xrange ,
7
8
text_type ,
@@ -76,7 +77,7 @@ def tree_entries_from_data(data):
76
77
# default encoding for strings in git is utf8
77
78
# Only use the respective unicode object if the byte stream was encoded
78
79
name = data [ns :i ]
79
- name = name . decode ( defenc , 'surrogateescape' )
80
+ name = safe_decode ( name )
80
81
81
82
# byte is NULL, get next 20
82
83
i += 1
Original file line number Diff line number Diff line change 16
16
from gitdb .util import bin_to_hex
17
17
from gitdb .base import IStream
18
18
from gitdb .typ import str_tree_type
19
+ from git .compat import PY3
19
20
21
+ from unittest .case import skipIf
20
22
from stat import (
21
23
S_IFDIR ,
22
24
S_IFREG ,
@@ -256,6 +258,12 @@ def test_tree_traversal_single(self):
256
258
assert entries
257
259
# END for each commit
258
260
259
- def test_tree_entries_from_data_with_failing_name_decode (self ):
261
+ @skipIf (PY3 , 'odd types returned ... maybe figure it out one day' )
262
+ def test_tree_entries_from_data_with_failing_name_decode_py2 (self ):
260
263
r = tree_entries_from_data (b'100644 \x9f \0 aaa' )
261
- assert r == [(b'aaa' , 33188 , b'\x9f ' )], r
264
+ assert r == [('aaa' , 33188 , u'\udc9f ' )], r
265
+
266
+ @skipIf (not PY3 , 'odd types returned ... maybe figure it out one day' )
267
+ def test_tree_entries_from_data_with_failing_name_decode_py3 (self ):
268
+ r = tree_entries_from_data (b'100644 \x9f \0 aaa' )
269
+ assert r == [(b'aaa' , 33188 , '\udc9f ' )], r
You can’t perform that action at this time.
0 commit comments