Author: Armin Rigo <[email protected]>
Branch:
Changeset: r48756:a42afd412616
Date: 2011-11-04 16:12 +0100
http://bitbucket.org/pypy/pypy/changeset/a42afd412616/
Log: merge heads
diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
@@ -7407,7 +7407,7 @@
expected = """
[p22, p18, i1, i2]
call(i2, descr=nonwritedescr)
- setfield_gc(p22, i1, descr=valuedescr)
+ setfield_gc(p22, i1, descr=valuedescr)
jump(p22, p18, i1, i1)
"""
self.optimize_loop(ops, expected, preamble, expected_short=short)
@@ -7434,7 +7434,7 @@
def test_cache_setarrayitem_across_loop_boundaries(self):
ops = """
[p1]
- p2 = getarrayitem_gc(p1, 3, descr=arraydescr)
+ p2 = getarrayitem_gc(p1, 3, descr=arraydescr)
guard_nonnull_class(p2, ConstClass(node_vtable)) []
call(p2, descr=nonwritedescr)
p3 = new_with_vtable(ConstClass(node_vtable))
diff --git a/pypy/objspace/std/test/test_sliceobject.py
b/pypy/objspace/std/test/test_sliceobject.py
--- a/pypy/objspace/std/test/test_sliceobject.py
+++ b/pypy/objspace/std/test/test_sliceobject.py
@@ -42,6 +42,23 @@
getslice(length, mystart, mystop))
+ def test_indexes4(self):
+ space = self.space
+ w = space.wrap
+
+ def getslice(length, start, stop, step):
+ return [i for i in range(0, length, step) if start <= i < stop]
+
+ for step in [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5, None]:
+ for length in range(5):
+ for start in range(-2*length-2, 2*length+3) + [None]:
+ for stop in range(-2*length-2, 2*length+3) + [None]:
+ sl = space.newslice(w(start), w(stop), w(step))
+ mystart, mystop, mystep, slicelength =
sl.indices4(space, length)
+ assert len(range(length)[start:stop:step]) ==
slicelength
+ assert slice(start, stop, step).indices(length) == (
+ mystart, mystop, mystep)
+
class AppTest_SliceObject:
def test_new(self):
def cmp_slice(sl1, sl2):
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
@@ -10,7 +10,7 @@
from pypy.objspace.std import slicetype, newformat
from pypy.objspace.std.tupleobject import W_TupleObject
from pypy.rlib.rarithmetic import intmask, ovfcheck
-from pypy.rlib.objectmodel import compute_hash
+from pypy.rlib.objectmodel import compute_hash, specialize
from pypy.rlib.rstring import UnicodeBuilder
from pypy.rlib.runicode import unicode_encode_unicode_escape
from pypy.module.unicodedata import unicodedb
@@ -475,32 +475,29 @@
index = length
return index
-def _convert_idx_params(space, w_self, w_sub, w_start, w_end,
upper_bound=False):
- assert isinstance(w_sub, W_UnicodeObject)
[email protected](4)
+def _convert_idx_params(space, w_self, w_start, w_end, upper_bound=False):
self = w_self._value
- sub = w_sub._value
start, end = slicetype.unwrap_start_stop(
space, len(self), w_start, w_end, upper_bound)
- return (self, sub, start, end)
-_convert_idx_params._annspecialcase_ = 'specialize:arg(5)'
+ return (self, start, end)
def unicode_endswith__Unicode_Unicode_ANY_ANY(space, w_self, w_substr,
w_start, w_end):
- self, substr, start, end = _convert_idx_params(space, w_self, w_substr,
+ self, start, end = _convert_idx_params(space, w_self,
w_start, w_end, True)
- return space.newbool(stringendswith(self, substr, start, end))
+ return space.newbool(stringendswith(self, w_substr._value, start, end))
def unicode_startswith__Unicode_Unicode_ANY_ANY(space, w_self, w_substr,
w_start, w_end):
- self, substr, start, end = _convert_idx_params(space, w_self, w_substr,
- w_start, w_end, True)
+ self, start, end = _convert_idx_params(space, w_self, w_start, w_end, True)
# XXX this stuff can be waaay better for ootypebased backends if
# we re-use more of our rpython machinery (ie implement startswith
# with additional parameters as rpython)
- return space.newbool(stringstartswith(self, substr, start, end))
+ return space.newbool(stringstartswith(self, w_substr._value, start, end))
def unicode_startswith__Unicode_Tuple_ANY_ANY(space, w_unistr, w_prefixes,
w_start, w_end):
- unistr, _, start, end = _convert_idx_params(space, w_unistr,
space.wrap(u''),
- w_start, w_end, True)
+ unistr, start, end = _convert_idx_params(space, w_unistr,
+ w_start, w_end, True)
for w_prefix in space.fixedview(w_prefixes):
prefix = space.unicode_w(w_prefix)
if stringstartswith(unistr, prefix, start, end):
@@ -509,7 +506,7 @@
def unicode_endswith__Unicode_Tuple_ANY_ANY(space, w_unistr, w_suffixes,
w_start, w_end):
- unistr, _, start, end = _convert_idx_params(space, w_unistr,
space.wrap(u''),
+ unistr, start, end = _convert_idx_params(space, w_unistr,
w_start, w_end, True)
for w_suffix in space.fixedview(w_suffixes):
suffix = space.unicode_w(w_suffix)
@@ -615,37 +612,32 @@
return space.newlist(lines)
def unicode_find__Unicode_Unicode_ANY_ANY(space, w_self, w_substr, w_start,
w_end):
- self, substr, start, end = _convert_idx_params(space, w_self, w_substr,
- w_start, w_end)
- return space.wrap(self.find(substr, start, end))
+ self, start, end = _convert_idx_params(space, w_self, w_start, w_end)
+ return space.wrap(self.find(w_substr._value, start, end))
def unicode_rfind__Unicode_Unicode_ANY_ANY(space, w_self, w_substr, w_start,
w_end):
- self, substr, start, end = _convert_idx_params(space, w_self, w_substr,
- w_start, w_end)
- return space.wrap(self.rfind(substr, start, end))
+ self, start, end = _convert_idx_params(space, w_self, w_start, w_end)
+ return space.wrap(self.rfind(w_substr._value, start, end))
def unicode_index__Unicode_Unicode_ANY_ANY(space, w_self, w_substr, w_start,
w_end):
- self, substr, start, end = _convert_idx_params(space, w_self, w_substr,
- w_start, w_end)
- index = self.find(substr, start, end)
+ self, start, end = _convert_idx_params(space, w_self, w_start, w_end)
+ index = self.find(w_substr._value, start, end)
if index < 0:
raise OperationError(space.w_ValueError,
space.wrap('substring not found'))
return space.wrap(index)
def unicode_rindex__Unicode_Unicode_ANY_ANY(space, w_self, w_substr, w_start,
w_end):
- self, substr, start, end = _convert_idx_params(space, w_self, w_substr,
- w_start, w_end)
- index = self.rfind(substr, start, end)
+ self, start, end = _convert_idx_params(space, w_self, w_start, w_end)
+ index = self.rfind(w_substr._value, start, end)
if index < 0:
raise OperationError(space.w_ValueError,
space.wrap('substring not found'))
return space.wrap(index)
def unicode_count__Unicode_Unicode_ANY_ANY(space, w_self, w_substr, w_start,
w_end):
- self, substr, start, end = _convert_idx_params(space, w_self, w_substr,
- w_start, w_end)
- return space.wrap(self.count(substr, start, end))
+ self, start, end = _convert_idx_params(space, w_self, w_start, w_end)
+ return space.wrap(self.count(w_substr._value, start, end))
def unicode_split__Unicode_None_ANY(space, w_self, w_none, w_maxsplit):
maxsplit = space.int_w(w_maxsplit)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit