[pypy-commit] pypy unicode-utf8: fix off-by-one

mattip pypy.commits at gmail.com
Sun Sep 16 14:24:34 EDT 2018


Author: Matti Picus <matti.picus at gmail.com>
Branch: unicode-utf8
Changeset: r95128:5437a5a4f8de
Date: 2018-09-16 21:22 +0300
http://bitbucket.org/pypy/pypy/changeset/5437a5a4f8de/

Log:	fix off-by-one

diff --git a/pypy/interpreter/unicodehelper.py b/pypy/interpreter/unicodehelper.py
--- a/pypy/interpreter/unicodehelper.py
+++ b/pypy/interpreter/unicodehelper.py
@@ -1070,14 +1070,14 @@
         else:
             res_8, newindex = errorhandler(
                 errors, public_encoding_name, 'surrogates not allowed',
-                s, pos - 1, pos)
+                s, pos, pos+1)
             for cp in rutf8.Utf8StringIterator(res_8):
                 if cp < 0xD800:
                     _STORECHAR(result, cp, byteorder)
                 else:
                     errorhandler('strict', public_encoding_name,
                                  'surrogates not allowed',
-                                 s, pos-1, pos)
+                                 s, pos, pos+1)
             if index != newindex:  # Should be uncommon
                 index = newindex
                 pos = rutf8._pos_at_index(s, newindex)


More information about the pypy-commit mailing list