Skip to content

Commit 19099f9

Browse files
committed
Python 3 compat fixes
Specifically "string_escape" does not exist as an encoding anymore.
1 parent 7fbc182 commit 19099f9

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

git/diff.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ def decode_path(path, has_ab_prefix=True):
2727
return None
2828

2929
if path.startswith(b'"') and path.endswith(b'"'):
30-
path = path[1:-1].decode('string_escape')
30+
path = (path[1:-1].replace(b'\\n', b'\n')
31+
.replace(b'\\t', b'\t')
32+
.replace(b'\\"', b'"')
33+
.replace(b'\\\\', b'\\'))
3134

3235
if has_ab_prefix:
3336
assert path.startswith(b'a/') or path.startswith(b'b/')

git/test/test_diff.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def test_diff_unsafe_paths(self):
158158
self.assertEqual(res[5].b_path, u'path/with\nnewline')
159159
self.assertEqual(res[6].b_path, u'path/with spaces')
160160
self.assertEqual(res[7].b_path, u'path/with-question-mark?')
161-
self.assertEqual(res[8].b_path, ur'path/¯\_(ツ)_|¯')
161+
self.assertEqual(res[8].b_path, u'path/¯\\_(ツ)_|¯')
162162

163163
# The "Moves"
164164
# NOTE: The path prefixes a/ and b/ here are legit! We're actually

0 commit comments

Comments
 (0)