[pypy-commit] pypy unicode-utf8-py3: decode returns a triplet (needed by implement_codecs.py)
mattip
pypy.commits at gmail.com
Sat Aug 4 18:01:34 EDT 2018
Author: Matti Picus <matti.picus at gmail.com>
Branch: unicode-utf8-py3
Changeset: r94940:418b72a670e7
Date: 2018-08-04 14:53 -0700
http://bitbucket.org/pypy/pypy/changeset/418b72a670e7/
Log: decode returns a triplet (needed by implement_codecs.py)
diff --git a/pypy/interpreter/astcompiler/test/test_compiler.py b/pypy/interpreter/astcompiler/test/test_compiler.py
--- a/pypy/interpreter/astcompiler/test/test_compiler.py
+++ b/pypy/interpreter/astcompiler/test/test_compiler.py
@@ -1,5 +1,6 @@
from __future__ import division
import py, sys
+from pytest import raises
from pypy.interpreter.astcompiler import codegen, astbuilder, symtable, optimize
from pypy.interpreter.pyparser import pyparse
from pypy.interpreter.pyparser.test import expressions
diff --git a/pypy/interpreter/pyparser/parsestring.py b/pypy/interpreter/pyparser/parsestring.py
--- a/pypy/interpreter/pyparser/parsestring.py
+++ b/pypy/interpreter/pyparser/parsestring.py
@@ -95,7 +95,7 @@
unicodehelper.check_utf8_or_raise(space, s, ps, q)
substr = decode_unicode_utf8(space, s, ps, q)
r = unicodehelper.decode_unicode_escape(space, substr)
- v, length = r
+ v, length, pos = r
return space.newutf8(v, length)
assert 0 <= ps <= q
diff --git a/pypy/interpreter/unicodehelper.py b/pypy/interpreter/unicodehelper.py
--- a/pypy/interpreter/unicodehelper.py
+++ b/pypy/interpreter/unicodehelper.py
@@ -145,12 +145,11 @@
from pypy.module._codecs import interp_codecs
state = space.fromcache(interp_codecs.CodecState)
unicodedata_handler = state.get_unicodedata_handler(space)
- result_utf8, length = str_decode_unicode_escape(
+ return str_decode_unicode_escape(
string, "strict",
final=True,
errorhandler=state.decode_error_handler,
ud_handler=unicodedata_handler)
- return result_utf8, length
def decode_raw_unicode_escape(space, string):
return str_decode_raw_unicode_escape(
@@ -469,7 +468,7 @@
def str_decode_unicode_escape(s, errors, final, errorhandler, ud_handler):
size = len(s)
if size == 0:
- return '', 0
+ return '', 0, 0
builder = rutf8.Utf8StringBuilder(size)
pos = 0
@@ -588,7 +587,7 @@
builder.append_char('\\')
builder.append_code(ord(ch))
- return builder.build(), builder.getlength()
+ return builder.build(), builder.getlength(), pos
def wcharpsize2utf8(space, wcharp, size):
"""Safe version of rffi.wcharpsize2utf8.
More information about the pypy-commit
mailing list