Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9e4a454

Browse files
committed
fix(surrogateescape): enable on py2, fix tests
1 parent93d5302 commit9e4a454

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

‎git/compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,6 @@ def register_surrogateescape():
308308

309309

310310
try:
311-
"hello".decode(defenc,"surrogateescape")
311+
b"100644\x9f\0aaa".decode(defenc,"surrogateescape")
312312
except:
313313
register_surrogateescape()

‎git/objects/fun.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
fromstatimportS_ISDIR
33
fromgit.compatimport (
44
byte_ord,
5+
safe_decode,
56
defenc,
67
xrange,
78
text_type,
@@ -76,7 +77,7 @@ def tree_entries_from_data(data):
7677
# default encoding for strings in git is utf8
7778
# Only use the respective unicode object if the byte stream was encoded
7879
name=data[ns:i]
79-
name=name.decode(defenc,'surrogateescape')
80+
name=safe_decode(name)
8081

8182
# byte is NULL, get next 20
8283
i+=1

‎git/test/test_fun.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
fromgitdb.utilimportbin_to_hex
1717
fromgitdb.baseimportIStream
1818
fromgitdb.typimportstr_tree_type
19+
fromgit.compatimportPY3
1920

21+
fromunittest.caseimportskipIf
2022
fromstatimport (
2123
S_IFDIR,
2224
S_IFREG,
@@ -256,6 +258,12 @@ def test_tree_traversal_single(self):
256258
assertentries
257259
# END for each commit
258260

259-
deftest_tree_entries_from_data_with_failing_name_decode(self):
261+
@skipIf(PY3,'odd types returned ... maybe figure it out one day')
262+
deftest_tree_entries_from_data_with_failing_name_decode_py2(self):
260263
r=tree_entries_from_data(b'100644\x9f\0aaa')
261-
assertr== [(b'aaa',33188,b'\x9f')],r
264+
assertr== [('aaa',33188,u'\udc9f')],r
265+
266+
@skipIf(notPY3,'odd types returned ... maybe figure it out one day')
267+
deftest_tree_entries_from_data_with_failing_name_decode_py3(self):
268+
r=tree_entries_from_data(b'100644\x9f\0aaa')
269+
assertr== [(b'aaa',33188,'\udc9f')],r

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp