Skip to content

Commit c5f3c58

Browse files
Harmon758Byron
authored andcommitted
Remove and replace compat._unichr
1 parent c7392d6 commit c5f3c58

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

‎git/compat.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,8 @@ def b(data):
118118
return data
119119

120120
if PY3:
121-
_unichr = chr
122121
bytes_chr = lambda code: bytes((code,))
123122
else:
124-
_unichr = unichr
125123
bytes_chr = chr
126124

127125
def surrogateescape_handler(exc):
@@ -176,9 +174,9 @@ def replace_surrogate_encode(mystring, exc):
176174
# 0x80 | (code & 0x3f)]
177175
# Is this a good idea?
178176
if 0xDC00 <= code <= 0xDC7F:
179-
decoded.append(_unichr(code - 0xDC00))
177+
decoded.append(chr(code - 0xDC00))
180178
elif code <= 0xDCFF:
181-
decoded.append(_unichr(code - 0xDC00))
179+
decoded.append(chr(code - 0xDC00))
182180
else:
183181
raise NotASurrogateError
184182
return str().join(decoded)
@@ -197,9 +195,9 @@ def replace_surrogate_decode(mybytes):
197195
else:
198196
code = ord(ch)
199197
if 0x80 <= code <= 0xFF:
200-
decoded.append(_unichr(0xDC00 + code))
198+
decoded.append(chr(0xDC00 + code))
201199
elif code <= 0x7F:
202-
decoded.append(_unichr(code))
200+
decoded.append(chr(code))
203201
else:
204202
# # It may be a bad byte
205203
# # Try swallowing it.

0 commit comments

Comments
 (0)