Author: Richard Plangger <planri...@gmail.com> Branch: py3.5-text-utf8 Changeset: r90403:2694e2b25754 Date: 2017-02-27 15:37 +0100 http://bitbucket.org/pypy/pypy/changeset/2694e2b25754/
Log: (ronan, arigato, plan_rich) make the W_UnicodeObject elidable by the jit, the exception is propagated one level up diff --git a/pypy/objspace/std/unicodeobject.py b/pypy/objspace/std/unicodeobject.py --- a/pypy/objspace/std/unicodeobject.py +++ b/pypy/objspace/std/unicodeobject.py @@ -81,9 +81,16 @@ return self._value def text_w(self, space): - identifier = jit.conditional_call_elidable( - self._utf8, g_encode_utf8, space, self, - self._value) + try: + identifier = jit.conditional_call_elidable( + self._utf8, g_encode_utf8, self._value) + except SurrogateError as e: + raise OperationError(space.w_UnicodeEncodeError, + space.newtuple([space.newtext('utf-8'), + self, + space.newint(e.index-1), + space.newint(e.index), + space.newtext("surrogates not allowed")])) if not jit.isconstant(self): self._utf8 = identifier return identifier @@ -1256,17 +1263,9 @@ return u''.join(result) @jit.elidable -def g_encode_utf8(space, w_value, value): +def g_encode_utf8(value): """This is a global function because of jit.conditional_call_value""" - try: - return unicode_encode_utf8_forbid_surrogates(value, len(value)) - except SurrogateError as e: - raise OperationError(space.w_UnicodeEncodeError, - space.newtuple([space.newtext('utf-8'), - w_value, - space.newint(e.index-1), - space.newint(e.index), - space.newtext("surrogates not allowed")])) + return unicode_encode_utf8_forbid_surrogates(value, len(value)) _repr_function, _ = make_unicode_escape_function( pass_printable=True, unicode_output=True, quotes=True, prefix='') _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit