Author: Armin Rigo <[email protected]>
Branch: py3k
Changeset: r87269:80e7245f0eb0
Date: 2016-09-21 14:38 +0200
http://bitbucket.org/pypy/pypy/changeset/80e7245f0eb0/
Log: Manual merge of a translation fix I've done only in the py3.5 branch
(sorry)
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
@@ -77,19 +77,21 @@
def unicode_w(self, space):
return self._value
- @jit.elidable
def identifier_w(self, space):
- identifier = self._utf8
- if identifier is not None:
- return identifier
- u = self._value
- eh = unicodehelper.rpy_encode_error_handler()
try:
- identifier = unicode_encode_utf_8(u, len(u), None,
- errorhandler=eh)
- except unicodehelper.RUnicodeEncodeError as ue:
- raise wrap_encode_error(space, ue)
- self._utf8 = identifier
+ # call the elidable function, with a jit.call_shortcut in case
+ # self._utf8 is already computed
+ identifier = g_identifier_w(self, space)
+ except UnicodeEncodeError:
+ # bah, this is just to get an official app-level
+ # UnicodeEncodeError
+ u = self._value
+ eh = unicodehelper.rpy_encode_error_handler()
+ try:
+ identifier = unicode_encode_utf_8(u, len(u), None,
+ errorhandler=eh)
+ except unicodehelper.RUnicodeEncodeError as ue:
+ raise wrap_encode_error(space, ue)
return identifier
def listview_unicode(self):
@@ -1306,6 +1308,16 @@
return unicodehelper.encode_utf8(space, u''.join(result),
allow_surrogates=allow_surrogates)
[email protected]
[email protected]_shortcut
+def g_identifier_w(self, space):
+ """This is a global function because of @jit.call_shortcut"""
+ identifier = self._utf8
+ if identifier is not None:
+ return identifier
+ identifier = self._value.encode('utf-8')
+ self._utf8 = identifier
+ return identifier
_repr_function, _ = make_unicode_escape_function(
pass_printable=True, unicode_output=True, quotes=True, prefix='')
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit