Author: Armin Rigo <[email protected]>
Branch: py3.5
Changeset: r88773:4ed461a08c1e
Date: 2016-11-30 15:34 +0000
http://bitbucket.org/pypy/pypy/changeset/4ed461a08c1e/
Log: fix test, slightly improve code generated
diff --git a/pypy/module/pypyjit/test_pypy_c/test_string.py
b/pypy/module/pypyjit/test_pypy_c/test_string.py
--- a/pypy/module/pypyjit/test_pypy_c/test_string.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_string.py
@@ -95,7 +95,7 @@
jump(..., descr=...)
""" % (-sys.maxint-1,))
- def test_long(self):
+ def test_int_base_16(self):
def main(n):
i = 1
while i < n:
@@ -127,17 +127,20 @@
i87 = int_mul(i85, 10)
i19 = int_sub(i6, i87)
- i23 = strgetitem(p10, i19)
- p25 = newstr(1)
- strsetitem(p25, 0, i23)
- p93 = call_r(ConstClass(fromstr), p25, 16, descr=<Callr . ri EF=4>)
+ i23 = unicodegetitem(ConstPtr(ptr92), i19)
+ p25 = newunicode(1)
+ unicodesetitem(p25, 0, i23)
+ p97 = call_r(ConstClass(_rpy_unicode_to_decimal_w), p25,
descr=<Callr . r EF=5>)
guard_no_exception(descr=...)
- i95 = getfield_gc_i(p93, descr=<FieldS
rpython.rlib.rbigint.rbigint.inst_size .*>)
- i96 = int_gt(i95, #)
- guard_false(i96, descr=...)
- i94 = call_i(ConstClass(rbigint._toint_helper), p93, descr=<Calli
. r EF=4>)
+ i98 = unicodelen(p97)
+ p99 = force_token()
+ setfield_gc(p0, p99, descr=<FieldP
pypy.interpreter.pyframe.PyFrame.vable_token .>)
+ p104 = call_may_force_r(ConstClass(unicode_encode_utf_8_impl),
p97, i98, ConstPtr(ptr101), 1, 1, descr=<Callr . ririi EF=7>)
+ guard_not_forced(descr=...)
guard_no_exception(descr=...)
- i95 = int_add_ovf(i6, i94)
+ i107 = call_i(ConstClass(string_to_int), p104, 16, descr=<Calli .
ri EF=4>)
+ guard_no_exception(descr=...)
+ i95 = int_add_ovf(i6, i107)
guard_no_overflow(descr=...)
--TICK--
jump(..., descr=...)
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
@@ -1257,7 +1257,11 @@
def unicode_to_decimal_w(space, w_unistr, allow_surrogates=False):
if not isinstance(w_unistr, W_UnicodeObject):
raise oefmt(space.w_TypeError, "expected unicode, got '%T'", w_unistr)
- unistr = w_unistr._value
+ value = _rpy_unicode_to_decimal_w(space, w_unistr._value)
+ return unicodehelper.encode_utf8(space, value,
+ allow_surrogates=allow_surrogates)
+
+def _rpy_unicode_to_decimal_w(space, unistr):
result = [u'\0'] * len(unistr)
for i in xrange(len(unistr)):
uchr = ord(unistr[i])
@@ -1270,8 +1274,7 @@
except KeyError:
pass
result[i] = unichr(uchr)
- return unicodehelper.encode_utf8(space, u''.join(result),
- allow_surrogates=allow_surrogates)
+ return u''.join(result)
@jit.elidable
def g_encode_utf8(value):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit