Author: Brian Kearns <bdkea...@gmail.com> Branch: numpypy-nditer Changeset: r69736:6d344175d0f5 Date: 2014-03-05 16:10 -0500 http://bitbucket.org/pypy/pypy/changeset/6d344175d0f5/
Log: merge default diff --git a/pypy/interpreter/special.py b/pypy/interpreter/special.py --- a/pypy/interpreter/special.py +++ b/pypy/interpreter/special.py @@ -2,16 +2,10 @@ class Ellipsis(W_Root): - def __init__(self, space): - self.space = space - def descr__repr__(self, space): return space.wrap('Ellipsis') class NotImplemented(W_Root): - def __init__(self, space): - self.space = space - def descr__repr__(self, space): return space.wrap('NotImplemented') diff --git a/pypy/module/micronumpy/compile.py b/pypy/module/micronumpy/compile.py --- a/pypy/module/micronumpy/compile.py +++ b/pypy/module/micronumpy/compile.py @@ -71,8 +71,8 @@ def __init__(self): """NOT_RPYTHON""" self.fromcache = InternalSpaceCache(self).getorbuild - self.w_Ellipsis = special.Ellipsis(self) - self.w_NotImplemented = special.NotImplemented(self) + self.w_Ellipsis = special.Ellipsis() + self.w_NotImplemented = special.NotImplemented() def _freeze_(self): return True diff --git a/pypy/module/pypyjit/test_pypy_c/test_misc.py b/pypy/module/pypyjit/test_pypy_c/test_misc.py --- a/pypy/module/pypyjit/test_pypy_c/test_misc.py +++ b/pypy/module/pypyjit/test_pypy_c/test_misc.py @@ -176,14 +176,14 @@ loop, = log.loops_by_filename(self.filepath) assert loop.match(""" guard_not_invalidated? - i16 = int_lt(i11, i12) - guard_true(i16, descr=...) + i16 = int_ge(i11, i12) + guard_false(i16, descr=...) i20 = int_add(i11, 1) i21 = force_token() setfield_gc(p4, i20, descr=<.* .*W_AbstractSeqIterObject.inst_index .*>) guard_not_invalidated? - i25 = int_lt(i11, i9) - guard_true(i25, descr=...) + i25 = int_ge(i11, i9) + guard_false(i25, descr=...) i27 = int_add_ovf(i7, i11) guard_no_overflow(descr=...) --TICK-- @@ -214,10 +214,10 @@ i21 = force_token() setfield_gc(p4, i20, descr=<.* .*W_AbstractSeqIterObject.inst_index .*>) guard_not_invalidated? - i23 = int_ge(i18, 0) - guard_true(i23, descr=...) - i25 = int_lt(i18, i9) - guard_true(i25, descr=...) + i23 = int_lt(i18, 0) + guard_false(i23, descr=...) + i25 = int_ge(i18, i9) + guard_false(i25, descr=...) i27 = int_add_ovf(i7, i18) guard_no_overflow(descr=...) --TICK-- 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 @@ -80,7 +80,7 @@ i23 = strgetitem(p10, i19) p25 = newstr(1) strsetitem(p25, 0, i23) - p93 = call(ConstClass(fromstr2), p25, 16, descr=<Callr . ri EF=3>) + p93 = call(ConstClass(fromstr), p25, 16, descr=<Callr . ri EF=3>) guard_no_exception(descr=...) i94 = call(ConstClass(rbigint.toint), p93, descr=<Calli . r EF=3>) guard_no_exception(descr=...) diff --git a/pypy/objspace/std/longobject.py b/pypy/objspace/std/longobject.py --- a/pypy/objspace/std/longobject.py +++ b/pypy/objspace/std/longobject.py @@ -542,7 +542,7 @@ def _string_to_w_long(space, w_longtype, w_source, string, base=10): try: - bigint = rbigint.fromstr2(string, base) + bigint = rbigint.fromstr(string, base) except ParseStringError as e: from pypy.objspace.std.intobject import wrap_parsestringerror raise wrap_parsestringerror(space, e, w_source) diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py --- a/pypy/objspace/std/objspace.py +++ b/pypy/objspace/std/objspace.py @@ -58,8 +58,8 @@ self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True - self.w_NotImplemented = self.wrap(special.NotImplemented(self)) - self.w_Ellipsis = self.wrap(special.Ellipsis(self)) + self.w_NotImplemented = self.wrap(special.NotImplemented()) + self.w_Ellipsis = self.wrap(special.Ellipsis()) # types self.builtin_types = {} diff --git a/pypy/objspace/std/test/test_listobject.py b/pypy/objspace/std/test/test_listobject.py --- a/pypy/objspace/std/test/test_listobject.py +++ b/pypy/objspace/std/test/test_listobject.py @@ -431,7 +431,7 @@ intlist.find(w(4), 0, 2) -class AppTestW_ListObject(object): +class AppTestListObject(object): def setup_class(cls): import platform import sys @@ -525,6 +525,18 @@ l.__init__(assignment) assert l == list(assignment) + def test_range_init(self): + x = range(5,1) + assert x == [] + + x = range(1,10) + x[22:0:-1] == range(1,10) + + r = range(10, 10) + assert len(r) == 0 + assert list(reversed(r)) == [] + assert r[:] == [] + def test_extend_list(self): l = l0 = [1] l.extend([2]) @@ -609,24 +621,28 @@ def test_sort_key(self): def lower(x): return x.lower() l = ['a', 'C', 'b'] - l.sort(key = lower) + l.sort(key=lower) assert l == ['a', 'b', 'C'] l = [] - l.sort(key = lower) + l.sort(key=lower) assert l == [] - l = [ 'a' ] - l.sort(key = lower) - assert l == [ 'a' ] + l = ['a'] + l.sort(key=lower) + assert l == ['a'] + + r = range(10) + r.sort(key=lambda x: -x) + assert r == range(9, -1, -1) def test_sort_reversed(self): l = range(10) - l.sort(reverse = True) + l.sort(reverse=True) assert l == range(9, -1, -1) l = [] - l.sort(reverse = True) + l.sort(reverse=True) assert l == [] l = [1] - l.sort(reverse = True) + l.sort(reverse=True) assert l == [1] def test_sort_cmp_key_reverse(self): @@ -640,6 +656,17 @@ l.sort() assert l == ["a", "b", "c", "d"] + def test_sort_range(self): + l = range(3, 10, 3) + l.sort() + assert l == [3, 6, 9] + l.sort(reverse=True) + assert l == [9, 6, 3] + l.sort(reverse=True) + assert l == [9, 6, 3] + l.sort() + assert l == [3, 6, 9] + def test_getitem(self): l = [1, 2, 3, 4, 5, 6, 9] assert l[0] == 1 @@ -663,6 +690,23 @@ l = [] raises(IndexError, "l[1]") + def test_getitem_range(self): + l = range(5) + raises(IndexError, "l[-6]") + raises(IndexError, "l[5]") + assert l[0] == 0 + assert l[-1] == 4 + assert l[-2] == 3 + assert l[-5] == 0 + + l = range(1, 5) + raises(IndexError, "l[-5]") + raises(IndexError, "l[4]") + assert l[0] == 1 + assert l[-1] == 4 + assert l[-2] == 3 + assert l[-4] == 1 + def test_setitem(self): l = [] raises(IndexError, "l[1] = 2") @@ -675,6 +719,10 @@ l[0] = "2" assert l == ["2",3] + l = range(3) + l[0] = 1 + assert l == [1,1,2] + def test_delitem(self): l = [1, 2, 3, 4, 5, 6, 9] del l[0] @@ -740,6 +788,29 @@ assert l[1:0:None] == [] assert l[1:0] == [] + def test_getslice_invalid(self): + x = [1,2,3,4] + assert x[10:0] == [] + assert x[10:0:None] == [] + + x = range(1,5) + assert x[10:0] == [] + assert x[10:0:None] == [] + + assert x[0:22] == [1,2,3,4] + assert x[-1:10] == [4] + + assert x[0:22:None] == [1,2,3,4] + assert x[-1:10:None] == [4] + + def test_getslice_range_backwards(self): + x = range(1,10) + assert x[22:-10] == [] + assert x[22:-10:-1] == [9,8,7,6,5,4,3,2,1] + assert x[10:3:-1] == [9,8,7,6,5] + assert x[10:3:-2] == [9,7,5] + assert x[1:5:-1] == [] + def test_delall(self): l = l0 = [1,2,3] del l[:] @@ -777,6 +848,13 @@ l1 += [0] assert l1 == ['a', 'b', 'c', 0] + r1 = r2 = range(5) + assert r1 is r2 + r1 += [15] + assert r1 is r2 + assert r1 == [0, 1, 2, 3, 4, 15] + assert r2 == [0, 1, 2, 3, 4, 15] + def test_iadd_iterable(self): l = l0 = [1,2,3] l += iter([4,5]) @@ -784,8 +862,6 @@ assert l == [1,2,3,4,5] def test_iadd_subclass(self): - #XXX - skip("Maybe there is something wrong in descroperation?") class Bar(object): def __radd__(self, other): return ('radd', self, other) @@ -837,6 +913,13 @@ l *= 2 assert l == [0, 1, 0, 1] + r1 = r2 = range(3) + assert r1 is r2 + r1 *= 2 + assert r1 is r2 + assert r1 == [0, 1, 2, 0, 1, 2] + assert r2 == [0, 1, 2, 0, 1, 2] + def test_mul_errors(self): try: [1, 2, 3] * (3,) @@ -918,6 +1001,11 @@ assert l == [] assert l is l0 + l = [] + l2 = range(3) + l.__setslice__(0,3,l2) + assert l == [0,1,2] + def test_assign_extended_slice(self): l = l0 = ['a', 'b', 'c'] l[::-1] = ['a', 'b', 'c'] @@ -1004,10 +1092,6 @@ l.append(x) assert l == range(5) - l = range(4) - l.append(4) - assert l == range(5) - l = [1,2,3] l.append("a") assert l == [1,2,3,"a"] @@ -1016,6 +1100,22 @@ l.append(4.4) assert l == [1.1, 2.2, 3.3, 4.4] + l = range(4) + l.append(4) + assert l == range(5) + + l = range(5) + l.append(26) + assert l == [0,1,2,3,4,26] + + l = range(5) + l.append("a") + assert l == [0,1,2,3,4,"a"] + + l = range(5) + l.append(5) + assert l == [0,1,2,3,4,5] + def test_count(self): c = list('hello') assert c.count('l') == 2 @@ -1043,6 +1143,10 @@ l.insert(0,"a") assert l == ["a", 1, 2, 3] + l = range(3) + l.insert(1,5) + assert l == [0,5,1,2] + def test_pop(self): c = list('hello world') s = '' @@ -1055,6 +1159,7 @@ l = range(10) l.pop() assert l == range(9) + assert l.pop(0) == 0 l = [1.1, 2.2, 3.3] l.pop() @@ -1125,6 +1230,16 @@ c.reverse() assert ''.join(c) == 'dlrow olleh' + l = range(3) + l.reverse() + assert l == [2,1,0] + + r = range(3) + r[0] = 1 + assert r == [1, 1, 2] + r.reverse() + assert r == [2, 1, 1] + def test_reversed(self): assert list(list('hello').__reversed__()) == ['o', 'l', 'l', 'e', 'h'] assert list(reversed(list('hello'))) == ['o', 'l', 'l', 'e', 'h'] @@ -1389,106 +1504,27 @@ # assert l == ["hi!", "okT", "okL", "okL", "okS", "okU"] + def test_no_len_on_range_iter(self): + iterable = range(10) + raises(TypeError, len, iter(iterable)) -class AppTestForRangeLists(AppTestW_ListObject): - spaceconfig = {"objspace.std.withrangelist": True} - - def test_range_simple_backwards(self): - x = range(5,1) - assert x == [] - - def test_range_big_start(self): - x = range(1,10) - x[22:0:-1] == range(1,10) - - def test_range_list_invalid_slice(self): - x = [1,2,3,4] - assert x[10:0] == [] - assert x[10:0:None] == [] - - x = range(1,5) - assert x[10:0] == [] - assert x[10:0:None] == [] - - assert x[0:22] == [1,2,3,4] - assert x[-1:10] == [4] - - assert x[0:22:None] == [1,2,3,4] - assert x[-1:10:None] == [4] - - def test_range_backwards(self): - x = range(1,10) - assert x[22:-10] == [] - assert x[22:-10:-1] == [9,8,7,6,5,4,3,2,1] - assert x[10:3:-1] == [9,8,7,6,5] - assert x[10:3:-2] == [9,7,5] - assert x[1:5:-1] == [] - - def test_sort_range(self): - l = range(3,10,3) - l.sort() - assert l == [3, 6, 9] - l.sort(reverse = True) - assert l == [9, 6, 3] - l.sort(reverse = True) - assert l == [9, 6, 3] - l.sort() - assert l == [3, 6, 9] - - def test_slice(self): - l = [] - l2 = range(3) - l.__setslice__(0,3,l2) - assert l == [0,1,2] - - def test_getitem(self): - l = range(5) - raises(IndexError, "l[-6]") - raises(IndexError, "l[5]") - assert l[0] == 0 - assert l[-1] == 4 - assert l[-2] == 3 - assert l[-5] == 0 - - l = range(1, 5) - raises(IndexError, "l[-5]") - raises(IndexError, "l[4]") - assert l[0] == 1 - assert l[-1] == 4 - assert l[-2] == 3 - assert l[-4] == 1 - - def test_append(self): - l = range(5) - l.append(26) - assert l == [0,1,2,3,4,26] - - l = range(5) - l.append("a") - assert l == [0,1,2,3,4,"a"] - - l = range(5) - l.append(5) - assert l == [0,1,2,3,4,5] - - def test_pop(self): - l = range(3) - assert l.pop(0) == 0 - - def test_setitem(self): - l = range(3) - l[0] = 1 - assert l == [1,1,2] - - def test_inset(self): - l = range(3) - l.insert(1,5) - assert l == [0,5,1,2] - - def test_reverse(self): - l = range(3) - l.reverse() - assert l == [2,1,0] + def test_reduce(self): + if self.on_cpython: + skip("cpython raises TypeError") # XXX investigate + it = iter(range(10)) + assert it.next() == 0 + assert it.next() == 1 + assert it.next() == 2 + assert it.next() == 3 + seqiter_new, args = it.__reduce__() + assert it.next() == 4 + assert it.next() == 5 + it2 = seqiter_new(*args) + assert it2.next() == 4 + assert it2.next() == 5 + it3 = seqiter_new(*args) + assert it3.next() == 4 + assert it3.next() == 5 def test_issue1266(self): l = range(1) @@ -1520,7 +1556,114 @@ assert item11 in l[::11] -class AppTestWithoutStrategies(object): +class AppTestListObjectWithRangeList(AppTestListObject): + """Run the list object tests with range lists enabled. Tests should go in + AppTestListObject so they can be run -A against CPython as well. + """ + spaceconfig = {"objspace.std.withrangelist": True} + + +class AppTestRangeListForcing: + """Tests for range lists that test forcing. Regular tests should go in + AppTestListObject so they can be run -A against CPython as well. Separate + from AppTestListObjectWithRangeList so we don't silently overwrite tests + with the same names. + """ + spaceconfig = {"objspace.std.withrangelist": True} + + def setup_class(cls): + if cls.runappdirect: + py.test.skip("__pypy__.internal_repr() cannot be used to see " + "if a range list was forced on top of pypy-c") + cls.w_not_forced = cls.space.appexec([], """(): + import __pypy__ + def f(r): + return (isinstance(r, list) and + "RangeListStrategy" in __pypy__.internal_repr(r)) + return f + """) + + def test_simple(self): + result = [] + r = range(1, 8, 2) + for i in r: + result.append(i) + assert result == [1, 3, 5, 7] + assert self.not_forced(r) + + def test_getitem_slice(self): + result = [] + r = range(1, 100, 2) + for i in r[10:15]: + result.append(i) + assert result == [21, 23, 25, 27, 29] + assert not self.not_forced(r) + + def test_getitem_extended_slice(self): + result = [] + r = range(1, 100, 2) + for i in r[40:30:-2]: + result.append(i) + assert result == [81, 77, 73, 69, 65] + assert not self.not_forced(r) + + def test_repr(self): + r = range(5) + assert repr(r) == "[0, 1, 2, 3, 4]" + assert self.not_forced(r) + + def test_force(self): + r = range(10) + r[0] = 42 + assert not self.not_forced(r) + assert r == [42, 1, 2, 3, 4, 5, 6, 7, 8, 9] + + def test_reverse(self): + r = range(10) + r.reverse() + assert not self.not_forced(r) + assert r == range(9, -1, -1) + + def test_pop(self): + # RangeListStrategy + r = range(1, 10) + res = r.pop() + assert res == 9 + assert self.not_forced(r) + assert repr(r) == repr(range(1, 9)) + res = r.pop(0) + assert res == 1 + assert self.not_forced(r) + assert repr(r) == repr(range(2, 9)) + res = r.pop(len(r) - 1) + assert res == 8 + assert self.not_forced(r) + assert repr(r) == repr(range(2, 8)) + res = r.pop(2) + assert res == 4 + assert not self.not_forced(r) + assert r == [2, 3, 5, 6, 7] + res = r.pop(2) + assert res == 5 + assert not self.not_forced(r) + assert r == [2, 3, 6, 7] + + # SimpleRangeListStrategy + r = range(10) + res = r.pop() + assert res == 9 + assert self.not_forced(r) + res = r.pop() + assert res == 8 + assert repr(r) == repr(range(8)) + assert self.not_forced(r) + res = r.pop(0) + assert res == 0 + assert not self.not_forced(r) + assert r == [1, 2, 3, 4, 5, 6, 7] + + +class AppTestWithoutStrategies: spaceconfig = {"objspace.std.withliststrategies": False} def test_no_shared_empty_list(self): diff --git a/pypy/objspace/std/test/test_liststrategies.py b/pypy/objspace/std/test/test_liststrategies.py --- a/pypy/objspace/std/test/test_liststrategies.py +++ b/pypy/objspace/std/test/test_liststrategies.py @@ -6,8 +6,8 @@ from pypy.objspace.std import listobject from pypy.objspace.std.test.test_listobject import TestW_ListObject + class TestW_ListStrategies(TestW_ListObject): - def test_check_strategy(self): space = self.space w = space.wrap @@ -236,7 +236,6 @@ l.setslice(0, 1, 2, make_range_list(space, 5, 1, 4)) assert isinstance(l.strategy, IntegerListStrategy) - def test_setslice_List(self): space = self.space @@ -705,7 +704,6 @@ w_l2.sort(False) assert space.eq_w(w_l, w_l2) - def test_listview_bytes_list(self): space = self.space w_l = W_ListObject(space, [space.wrap("a"), space.wrap("b")]) diff --git a/pypy/objspace/std/test/test_rangeobject.py b/pypy/objspace/std/test/test_rangeobject.py deleted file mode 100644 --- a/pypy/objspace/std/test/test_rangeobject.py +++ /dev/null @@ -1,154 +0,0 @@ -import py - -class AppTestRangeListObject(object): - spaceconfig = {"objspace.std.withrangelist": True} - - def setup_class(cls): - if cls.runappdirect: - py.test.skip("__pypy__.internal_repr() cannot be used to see " - "if a range list was forced on top of pypy-c") - cls.w_not_forced = cls.space.appexec([], """(): - import __pypy__ - def f(r): - return (isinstance(r, list) and - "RangeListStrategy" in __pypy__.internal_repr(r)) - return f - """) - cls.w_SORT_FORCES_LISTS = cls.space.wrap(False) - - def test_simple(self): - result = [] - r = range(1, 8, 2) - for i in r: - result.append(i) - assert result == [1, 3, 5, 7] - assert self.not_forced(r) - - def test_getitem_slice(self): - result = [] - r = range(1, 100, 2) - for i in r[10:15]: - result.append(i) - assert result == [21, 23, 25, 27, 29] - assert not self.not_forced(r) - - def test_getitem_extended_slice(self): - result = [] - r = range(1, 100, 2) - for i in r[40:30:-2]: - result.append(i) - assert result == [81, 77, 73, 69, 65] - assert not self.not_forced(r) - - def test_empty_range(self): - r = range(10, 10) - assert len(r) == 0 - assert list(reversed(r)) == [] - assert r[:] == [] - - def test_repr(self): - r = range(5) - assert repr(r) == "[0, 1, 2, 3, 4]" - assert self.not_forced(r) - - def test_force(self): - r = range(10) - r[0] = 42 - assert not self.not_forced(r) - assert r == [42, 1, 2, 3, 4, 5, 6, 7, 8, 9] - - def test_reverse(self): - r = range(10) - r.reverse() - assert not self.not_forced(r) - assert r == range(9, -1, -1) - r = range(3) - r[0] = 1 - assert r == [1, 1, 2] - r.reverse() - assert r == [2, 1, 1] - - r = range(10) - r.sort(key=lambda x: -x) - assert r == range(9, -1, -1) - def test_pop(self): - # RangeListStrategy - r = range(1, 10) - res = r.pop() - assert res == 9 - assert self.not_forced(r) - assert repr(r) == repr(range(1, 9)) - res = r.pop(0) - assert res == 1 - assert self.not_forced(r) - assert repr(r) == repr(range(2, 9)) - res = r.pop(len(r) - 1) - assert res == 8 - assert self.not_forced(r) - assert repr(r) == repr(range(2, 8)) - res = r.pop(2) - assert res == 4 - assert not self.not_forced(r) - assert r == [2, 3, 5, 6, 7] - res = r.pop(2) - assert res == 5 - assert not self.not_forced(r) - assert r == [2, 3, 6, 7] - - # SimpleRangeListStrategy - r = range(10) - res = r.pop() - assert res == 9 - assert self.not_forced(r) - res = r.pop() - assert res == 8 - assert repr(r) == repr(range(8)) - assert self.not_forced(r) - res = r.pop(0) - assert res == 0 - assert not self.not_forced(r) - assert r == [1, 2, 3, 4, 5, 6, 7] - - def test_getitem_simple(self): - r = range(4) - assert r[-1] == 3 - assert r[3] == 3 - assert r[-4] == 0 - raises(IndexError, r.__getitem__, -5) - raises(IndexError, r.__getitem__, 4) - - def test_reduce(self): - it = iter(range(10)) - assert it.next() == 0 - assert it.next() == 1 - assert it.next() == 2 - assert it.next() == 3 - seqiter_new, args = it.__reduce__() - assert it.next() == 4 - assert it.next() == 5 - it2 = seqiter_new(*args) - assert it2.next() == 4 - assert it2.next() == 5 - it3 = seqiter_new(*args) - assert it3.next() == 4 - assert it3.next() == 5 - - def test_no_len_on_range_iter(self): - iterable = range(10) - raises(TypeError, len, iter(iterable)) - - def test_inplace_add(self): - r1 = r2 = range(5) - assert r1 is r2 - r1 += [15] - assert r1 is r2 - assert r1 == [0, 1, 2, 3, 4, 15] - assert r2 == [0, 1, 2, 3, 4, 15] - - def test_inplace_mul(self): - r1 = r2 = range(3) - assert r1 is r2 - r1 *= 2 - assert r1 is r2 - assert r1 == [0, 1, 2, 0, 1, 2] - assert r2 == [0, 1, 2, 0, 1, 2] diff --git a/rpython/rlib/rbigint.py b/rpython/rlib/rbigint.py --- a/rpython/rlib/rbigint.py +++ b/rpython/rlib/rbigint.py @@ -254,28 +254,19 @@ @staticmethod @jit.elidable - def fromstr(s, base=0, ignore_l_suffix=False, fname='long'): - """As string_to_int(), but optionally ignores an optional 'l' or - 'L' suffix and returns an rbigint. - """ + def fromstr(s, base=0): + """As string_to_int(), but ignores an optional 'l' or 'L' suffix + and returns an rbigint.""" from rpython.rlib.rstring import NumberStringParser, \ strip_spaces s = literal = strip_spaces(s) - if (not ignore_l_suffix and (s.endswith('l') or s.endswith('L')) and - base < 22): + if (s.endswith('l') or s.endswith('L')) and base < 22: # in base 22 and above, 'L' is a valid digit! try: long('L',22) s = s[:-1] - parser = NumberStringParser(s, literal, base, fname) + parser = NumberStringParser(s, literal, base, 'long') return rbigint._from_numberstring_parser(parser) @staticmethod - @jit.elidable - def fromstr2(s, base=0): - """A sub-version of fromstr(), already elidable to be JIT-called - with only two arguments.""" - return rbigint.fromstr(s, base) - - @staticmethod def _from_numberstring_parser(parser): return parse_digit_string(parser) diff --git a/rpython/rlib/test/test_rbigint.py b/rpython/rlib/test/test_rbigint.py --- a/rpython/rlib/test/test_rbigint.py +++ b/rpython/rlib/test/test_rbigint.py @@ -214,19 +214,13 @@ from rpython.rlib.rstring import ParseStringError assert rbigint.fromstr('123L').tolong() == 123 assert rbigint.fromstr('123L ').tolong() == 123 - py.test.raises(ParseStringError, rbigint.fromstr, '123L ', - ignore_l_suffix=True) py.test.raises(ParseStringError, rbigint.fromstr, 'L') py.test.raises(ParseStringError, rbigint.fromstr, 'L ') - e = py.test.raises(ParseStringError, rbigint.fromstr, 'L ', - fname='int') - assert 'int()' in e.value.msg assert rbigint.fromstr('123L', 4).tolong() == 27 assert rbigint.fromstr('123L', 30).tolong() == 27000 + 1800 + 90 + 21 assert rbigint.fromstr('123L', 22).tolong() == 10648 + 968 + 66 + 21 assert rbigint.fromstr('123L', 21).tolong() == 441 + 42 + 3 assert rbigint.fromstr('1891234174197319').tolong() == 1891234174197319 - assert rbigint.fromstr2('123L', 4).tolong() == 27 def test_from_numberstring_parser(self): from rpython.rlib.rstring import NumberStringParser _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit