This instance will be upgraded to Heptapod 0.21.0rc3 on 2021-04-23 at 10:30 UTC+2 (a few minutes of down time)

test and fix in the ascii prefix shortcut

parent 95aba12aa102
Pipeline #18742 passed with stage
in 7 minutes and 21 seconds
......@@ -98,3 +98,9 @@ def test_utf8_encode_latin1_ascii_prefix():
b = utf8_encode_latin_1(utf8, None, None)
assert b == b'abcde\xe4g'
def test_latin1_shortcut_bug(space):
state = space.fromcache(CodecState)
handler = state.encode_error_handler
sin = u"a\xac\u1234\u20ac\u8000"
assert utf8_encode_latin_1(sin.encode("utf-8"), "backslashreplace", handler) == sin.encode("latin-1", "backslashreplace")
......@@ -161,9 +161,8 @@ def utf8_encode_latin_1(s, errors, errorhandler):
def _utf8_encode_latin_1_slowpath(s, first_non_ascii_char, errors, errorhandler):
size = len(s)
result = StringBuilder(size)
index = 0
result.append_slice(s, 0, first_non_ascii_char)
pos = first_non_ascii_char
pos = index = first_non_ascii_char
while pos < size:
ch = rutf8.codepoint_at_pos(s, pos)
if ch <= 0xFF:
......
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