Commit 5bf08f8b authored by Kirill Smelkov's avatar Kirill Smelkov

golang_str: def -> cdef for UTF-8b decode/encode routines

We use them only privately and only from pyx files.
parent 0cc53fdd
......@@ -2065,7 +2065,7 @@ cdef (rune, int) _utf8_decode_rune(const byte[::1] s):
# _utf8_decode_surrogateescape mimics s.decode('utf-8', 'surrogateescape') from py3.
def _utf8_decode_surrogateescape(const byte[::1] s): # -> unicode
cdef _utf8_decode_surrogateescape(const byte[::1] s): # -> unicode
if PY_MAJOR_VERSION >= 3:
if len(s) == 0:
return u'' # avoid out-of-bounds slice access on &s[0]
......@@ -2105,7 +2105,7 @@ def _utf8_decode_surrogateescape(const byte[::1] s): # -> unicode
# _utf8_encode_surrogateescape mimics s.encode('utf-8', 'surrogateescape') from py3.
def _utf8_encode_surrogateescape(s): # -> bytes
cdef _utf8_encode_surrogateescape(s): # -> bytes
assert isinstance(s, unicode)
if PY_MAJOR_VERSION >= 3:
return zunicode.encode(s, 'UTF-8', 'surrogateescape')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment