[pypy-commit] pypy default: split rlib.runicode.str_decode_utf_8 in two, else we had annotation problems when calling it to implement .decode('utf-8')
antocuni
noreply at buildbot.pypy.org
Sat Sep 1 10:48:05 CEST 2012
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch:
Changeset: r57066:81380e072e88
Date: 2012-09-01 10:47 +0200
http://bitbucket.org/pypy/pypy/changeset/81380e072e88/
Log: split rlib.runicode.str_decode_utf_8 in two, else we had annotation
problems when calling it to implement .decode('utf-8')
diff --git a/pypy/rlib/runicode.py b/pypy/rlib/runicode.py
--- a/pypy/rlib/runicode.py
+++ b/pypy/rlib/runicode.py
@@ -79,6 +79,9 @@
errorhandler=None):
if errorhandler is None:
errorhandler = raise_unicode_exception_decode
+ return str_decode_utf_8_impl(s, size, errors, final, errorhandler)
+
+def str_decode_utf_8_impl(s, size, errors, final, errorhandler):
if size == 0:
return u'', 0
diff --git a/pypy/rpython/rstr.py b/pypy/rpython/rstr.py
--- a/pypy/rpython/rstr.py
+++ b/pypy/rpython/rstr.py
@@ -19,18 +19,24 @@
self.rstr_decode_utf_8 = None
def ensure_ll_decode_utf8(self):
- from pypy.rlib.runicode import str_decode_utf_8, raise_unicode_exception_decode
- self.rstr_decode_utf_8 = func_with_new_name(str_decode_utf_8,
- 'rstr_decode_utf_8')
+ from pypy.rlib.runicode import str_decode_utf_8_impl
+ self.rstr_decode_utf_8 = func_with_new_name(str_decode_utf_8_impl,
+ 'rstr_decode_utf_8_impl')
@jit.elidable
def ll_decode_utf8(self, llvalue):
from pypy.rpython.annlowlevel import hlstr
value = hlstr(llvalue)
assert value is not None
- univalue, _ = self.rstr_decode_utf_8(value, len(value), 'strict')
+ univalue, _ = self.rstr_decode_utf_8(value, len(value), 'strict',
+ False, self.ll_raise_unicode_exception_decode)
return self.ll.llunicode(univalue)
+ def ll_raise_unicode_exception_decode(self, errors, encoding, msg, s,
+ startingpos, endingpos):
+ raise UnicodeDecodeError(encoding, s, startingpos, endingpos, msg)
+
+
class AbstractCharRepr(AbstractStringRepr):
pass
More information about the pypy-commit
mailing list