Author: Amaury Forgeot d'Arc <amaur...@gmail.com> Branch: py3k Changeset: r47950:459148c0f080 Date: 2011-10-11 23:41 +0200 http://bitbucket.org/pypy/pypy/changeset/459148c0f080/
Log: Remove all references to the __getslice__ methods and opcodes space.getslice() still exists, and delegates to getitem. diff --git a/pypy/interpreter/astcompiler/codegen.py b/pypy/interpreter/astcompiler/codegen.py --- a/pypy/interpreter/astcompiler/codegen.py +++ b/pypy/interpreter/astcompiler/codegen.py @@ -100,14 +100,6 @@ ast.Del : ops.DELETE_SUBSCR }) -slice_operations = misc.dict_to_switch({ - ast.AugLoad : ops.SLICE, - ast.Load : ops.SLICE, - ast.AugStore : ops.STORE_SLICE, - ast.Store : ops.STORE_SLICE, - ast.Del : ops.DELETE_SLICE -}) - class __extend__(ast.GeneratorExp): @@ -1081,35 +1073,6 @@ else: raise AssertionError("unknown context") - def _simple_slice(self, slc, ctx): - slice_offset = 0 - stack_count = 0 - if slc.lower: - slice_offset += 1 - stack_count += 1 - if ctx != ast.AugStore: - slc.lower.walkabout(self) - if slc.upper: - slice_offset += 2 - stack_count += 1 - if ctx != ast.AugStore: - slc.upper.walkabout(self) - if ctx == ast.AugLoad: - if stack_count == 0: - self.emit_op(ops.DUP_TOP) - elif stack_count == 1: - self.emit_op_arg(ops.DUP_TOPX, 2) - elif stack_count == 2: - self.emit_op_arg(ops.DUP_TOPX, 3) - elif ctx == ast.AugStore: - if stack_count == 0: - self.emit_op(ops.ROT_TWO) - elif stack_count == 1: - self.emit_op(ops.ROT_THREE) - elif stack_count == 2: - self.emit_op(ops.ROT_FOUR) - self.emit_op(slice_operations(ctx) + slice_offset) - def _complex_slice(self, slc, ctx): if slc.lower: slc.lower.walkabout(self) @@ -1146,10 +1109,7 @@ self.load_const(self.space.w_Ellipsis) elif isinstance(slc, ast.Slice): kind = "slice" - if not slc.step: - self._simple_slice(slc, ctx) - return - elif ctx != ast.AugStore: + if ctx != ast.AugStore: self._complex_slice(slc, ctx) elif isinstance(slc, ast.ExtSlice): kind = "extended slice" diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py --- a/pypy/interpreter/baseobjspace.py +++ b/pypy/interpreter/baseobjspace.py @@ -1435,9 +1435,6 @@ ('getitem', 'getitem', 2, ['__getitem__']), ('setitem', 'setitem', 3, ['__setitem__']), ('delitem', 'delitem', 2, ['__delitem__']), - ('getslice', 'getslice', 3, ['__getslice__']), - ('setslice', 'setslice', 4, ['__setslice__']), - ('delslice', 'delslice', 3, ['__delslice__']), ('trunc', 'trunc', 1, ['__trunc__']), ('pos', 'pos', 1, ['__pos__']), ('neg', 'neg', 1, ['__neg__']), diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -427,68 +427,6 @@ INPLACE_XOR = binaryoperation("inplace_xor") INPLACE_OR = binaryoperation("inplace_or") - def slice(self, w_start, w_end): - w_obj = self.popvalue() - w_result = self.space.getslice(w_obj, w_start, w_end) - self.pushvalue(w_result) - - def SLICE_0(self, oparg, next_instr): - self.slice(self.space.w_None, self.space.w_None) - - def SLICE_1(self, oparg, next_instr): - w_start = self.popvalue() - self.slice(w_start, self.space.w_None) - - def SLICE_2(self, oparg, next_instr): - w_end = self.popvalue() - self.slice(self.space.w_None, w_end) - - def SLICE_3(self, oparg, next_instr): - w_end = self.popvalue() - w_start = self.popvalue() - self.slice(w_start, w_end) - - def storeslice(self, w_start, w_end): - w_obj = self.popvalue() - w_newvalue = self.popvalue() - self.space.setslice(w_obj, w_start, w_end, w_newvalue) - - def STORE_SLICE_0(self, oparg, next_instr): - self.storeslice(self.space.w_None, self.space.w_None) - - def STORE_SLICE_1(self, oparg, next_instr): - w_start = self.popvalue() - self.storeslice(w_start, self.space.w_None) - - def STORE_SLICE_2(self, oparg, next_instr): - w_end = self.popvalue() - self.storeslice(self.space.w_None, w_end) - - def STORE_SLICE_3(self, oparg, next_instr): - w_end = self.popvalue() - w_start = self.popvalue() - self.storeslice(w_start, w_end) - - def deleteslice(self, w_start, w_end): - w_obj = self.popvalue() - self.space.delslice(w_obj, w_start, w_end) - - def DELETE_SLICE_0(self, oparg, next_instr): - self.deleteslice(self.space.w_None, self.space.w_None) - - def DELETE_SLICE_1(self, oparg, next_instr): - w_start = self.popvalue() - self.deleteslice(w_start, self.space.w_None) - - def DELETE_SLICE_2(self, oparg, next_instr): - w_end = self.popvalue() - self.deleteslice(self.space.w_None, w_end) - - def DELETE_SLICE_3(self, oparg, next_instr): - w_end = self.popvalue() - w_start = self.popvalue() - self.deleteslice(w_start, w_end) - def STORE_SUBSCR(self, oparg, next_instr): "obj[subscr] = newvalue" w_subscr = self.popvalue() diff --git a/pypy/module/__builtin__/interp_classobj.py b/pypy/module/__builtin__/interp_classobj.py --- a/pypy/module/__builtin__/interp_classobj.py +++ b/pypy/module/__builtin__/interp_classobj.py @@ -499,28 +499,6 @@ #XXX do I really need a next method? the old implementation had one, but I # don't see the point - def descr_getslice(self, space, w_i, w_j): - w_meth = self.getattr(space, '__getslice__', False) - if w_meth is not None: - return space.call_function(w_meth, w_i, w_j) - else: - return space.getitem(self, space.newslice(w_i, w_j, space.w_None)) - - def descr_setslice(self, space, w_i, w_j, w_sequence): - w_meth = self.getattr(space, '__setslice__', False) - if w_meth is not None: - space.call_function(w_meth, w_i, w_j, w_sequence) - else: - space.setitem(self, space.newslice(w_i, w_j, space.w_None), - w_sequence) - - def descr_delslice(self, space, w_i, w_j): - w_meth = self.getattr(space, '__delslice__', False) - if w_meth is not None: - space.call_function(w_meth, w_i, w_j) - else: - return space.delitem(self, space.newslice(w_i, w_j, space.w_None)) - def descr_call(self, space, __args__): w_meth = self.getattr(space, '__call__') return space.call_args(w_meth, __args__) @@ -771,9 +749,6 @@ __setitem__ = interp2app(W_InstanceObject.descr_setitem), __delitem__ = interp2app(W_InstanceObject.descr_delitem), __iter__ = interp2app(W_InstanceObject.descr_iter), - __getslice__ = interp2app(W_InstanceObject.descr_getslice), - __setslice__ = interp2app(W_InstanceObject.descr_setslice), - __delslice__ = interp2app(W_InstanceObject.descr_delslice), __call__ = interp2app(W_InstanceObject.descr_call), __nonzero__ = interp2app(W_InstanceObject.descr_nonzero), __cmp__ = interp2app(W_InstanceObject.descr_cmp), diff --git a/pypy/module/__builtin__/test/test_classobj.py b/pypy/module/__builtin__/test/test_classobj.py --- a/pypy/module/__builtin__/test/test_classobj.py +++ b/pypy/module/__builtin__/test/test_classobj.py @@ -606,22 +606,6 @@ skip("__rpow__(self, other, mod) seems not to work on CPython") assert pow(4, a, 5) == 625 - def test_getsetdelslice(self): - - class A: - def __getslice__(self, i, j): - return i + j - def __setslice__(self, i, j, seq): - self.last = (i, j, seq) - def __delslice__(self, i, j): - self.last = (i, j, None) - a = A() - assert a[1:3] == 4 - a[1:3] = [1, 2, 3] - assert a.last == (1, 3, [1, 2, 3]) - del a[1:4] - assert a.last == (1, 4, None) - def test_contains_bug(self): class A: def __iter__(self): diff --git a/pypy/module/array/interp_array.py b/pypy/module/array/interp_array.py --- a/pypy/module/array/interp_array.py +++ b/pypy/module/array/interp_array.py @@ -337,9 +337,6 @@ j += 1 return w_a - def getslice__Array_ANY_ANY(space, self, w_i, w_j): - return space.getitem(self, space.newslice(w_i, w_j, space.w_None)) - def setitem__Array_ANY_ANY(space, self, w_idx, w_item): idx, stop, step = space.decode_index(w_idx, self.len) if step != 0: @@ -372,9 +369,6 @@ self.buffer[i] = w_item.buffer[j] j += 1 - def setslice__Array_ANY_ANY_ANY(space, self, w_i, w_j, w_x): - space.setitem(self, space.newslice(w_i, w_j, space.w_None), w_x) - def array_append__Array_ANY(space, self, w_x): x = self.item_w(w_x) self.setlen(self.len + 1) @@ -447,9 +441,6 @@ self.setlen(0) self.fromsequence(w_lst) - def delslice__Array_ANY_ANY(space, self, w_i, w_j): - return space.delitem(self, space.newslice(w_i, w_j, space.w_None)) - # Add and mul methods def add__Array_Array(space, self, other): diff --git a/pypy/module/array/test/test_array.py b/pypy/module/array/test/test_array.py --- a/pypy/module/array/test/test_array.py +++ b/pypy/module/array/test/test_array.py @@ -307,11 +307,6 @@ raises(TypeError, "a[1:3] = self.array('I', [5, 6])") raises(TypeError, "a[1:3] = [5, 6]") - a = self.array('i', [1, 2, 3]) - assert a.__getslice__(1, 2) == a[1:2] - a.__setslice__(1, 2, self.array('i', (7,))) - assert a[0] == 1 and a[1] == 7 and a[2] == 3 - def test_resizingslice(self): a = self.array('i', [1, 2, 3]) a[1:2] = self.array('i', [7, 8, 9]) @@ -666,9 +661,6 @@ del a[1:3] assert repr(a) == "array('i', [1, 4, 5])" - a.__delslice__(0, 2) - assert repr(a) == "array('i', [5])" - def test_iter(self): a = self.array('i', [1, 2, 3]) assert 1 in a diff --git a/pypy/module/cpyext/include/object.h b/pypy/module/cpyext/include/object.h --- a/pypy/module/cpyext/include/object.h +++ b/pypy/module/cpyext/include/object.h @@ -214,9 +214,9 @@ binaryfunc sq_concat; ssizeargfunc sq_repeat; ssizeargfunc sq_item; - ssizessizeargfunc sq_slice; + void *was_sq_slice; ssizeobjargproc sq_ass_item; - ssizessizeobjargproc sq_ass_slice; + void *was_sq_ass_slice; objobjproc sq_contains; /* Added in release 2.0 */ binaryfunc sq_inplace_concat; diff --git a/pypy/module/cpyext/slotdefs.py b/pypy/module/cpyext/slotdefs.py --- a/pypy/module/cpyext/slotdefs.py +++ b/pypy/module/cpyext/slotdefs.py @@ -418,23 +418,10 @@ "x.__rmul__(n) <==> n*x"), SQSLOT("__getitem__", sq_item, slot_sq_item, wrap_sq_item, "x.__getitem__(y) <==> x[y]"), - SQSLOT("__getslice__", sq_slice, slot_sq_slice, wrap_ssizessizeargfunc, - "x.__getslice__(i, j) <==> x[i:j]\n\ - \n\ - Use of negative indices is not supported."), SQSLOT("__setitem__", sq_ass_item, slot_sq_ass_item, wrap_sq_setitem, "x.__setitem__(i, y) <==> x[i]=y"), SQSLOT("__delitem__", sq_ass_item, slot_sq_ass_item, wrap_sq_delitem, "x.__delitem__(y) <==> del x[y]"), - SQSLOT("__setslice__", sq_ass_slice, slot_sq_ass_slice, - wrap_ssizessizeobjargproc, - "x.__setslice__(i, j, y) <==> x[i:j]=y\n\ - \n\ - Use of negative indices is not supported."), - SQSLOT("__delslice__", sq_ass_slice, slot_sq_ass_slice, wrap_delslice, - "x.__delslice__(i, j) <==> del x[i:j]\n\ - \n\ - Use of negative indices is not supported."), SQSLOT("__contains__", sq_contains, slot_sq_contains, wrap_objobjproc, "x.__contains__(y) <==> y in x"), SQSLOT("__iadd__", sq_inplace_concat, NULL, diff --git a/pypy/module/cpyext/typeobjectdefs.py b/pypy/module/cpyext/typeobjectdefs.py --- a/pypy/module/cpyext/typeobjectdefs.py +++ b/pypy/module/cpyext/typeobjectdefs.py @@ -120,9 +120,7 @@ ("sq_concat", binaryfunc), ("sq_repeat", ssizeargfunc), ("sq_item", ssizeargfunc), - ("sq_slice", ssizessizeargfunc), ("sq_ass_item", ssizeobjargproc), - ("sq_ass_slice", ssizessizeobjargproc), ("sq_contains", objobjproc), ("sq_inplace_concat", binaryfunc), ("sq_inplace_repeat", ssizeargfunc), diff --git a/pypy/module/operator/__init__.py b/pypy/module/operator/__init__.py --- a/pypy/module/operator/__init__.py +++ b/pypy/module/operator/__init__.py @@ -17,11 +17,9 @@ appleveldefs = {} - app_names = ['__delslice__', '__getslice__', '__repeat__', '__setslice__', - 'countOf', 'delslice', 'getslice', 'indexOf', + app_names = ['__repeat__', 'countOf', 'indexOf', 'isMappingType', 'isNumberType', 'isSequenceType', - 'repeat', 'setslice', - 'attrgetter', 'itemgetter', 'methodcaller', + 'repeat', 'attrgetter', 'itemgetter', 'methodcaller', ] for name in app_names: diff --git a/pypy/module/operator/app_operator.py b/pypy/module/operator/app_operator.py --- a/pypy/module/operator/app_operator.py +++ b/pypy/module/operator/app_operator.py @@ -14,20 +14,6 @@ count += 1 return count -def delslice(obj, start, end): - 'delslice(a, b, c) -- Same as del a[b:c].' - if not isinstance(start, int) or not isinstance(end, int): - raise TypeError("an integer is expected") - del obj[start:end] -__delslice__ = delslice - -def getslice(a, start, end): - 'getslice(a, b, c) -- Same as a[b:c].' - if not isinstance(start, int) or not isinstance(end, int): - raise TypeError("an integer is expected") - return a[start:end] -__getslice__ = getslice - def indexOf(a, b): 'indexOf(a, b) -- Return the first index of b in a.' index = 0 @@ -62,11 +48,6 @@ __repeat__ = repeat -def setslice(a, b, c, d): - 'setslice(a, b, c, d) -- Same as a[b:c] = d.' - a[b:c] = d -__setslice__ = setslice - def attrgetter(attr, *attrs): if attrs: diff --git a/pypy/module/operator/interp_operator.py b/pypy/module/operator/interp_operator.py --- a/pypy/module/operator/interp_operator.py +++ b/pypy/module/operator/interp_operator.py @@ -33,8 +33,6 @@ 'delitem(a,b) -- Same as del a[b]' space.delitem(w_obj, w_key) -# delslice - def div(space, w_a, w_b): 'div(a, b) -- Same as a / b when __future__.division is no in effect' return space.div(w_a, w_b) @@ -55,8 +53,6 @@ 'getitem(a, b) -- Same as a[b].' return space.getitem(w_a, w_b) -# getslice - def gt(space, w_a, w_b): 'gt(a, b) -- Same as a>b.' return space.gt(w_a, w_b) @@ -133,7 +129,7 @@ 'pow(a, b) -- Same as a**b.' return space.pow(w_a, w_b, space.w_None) -# reapeat +# repeat def rshift(space, w_a, w_b): 'rshift(a, b) -- Same as a >> b.' @@ -145,8 +141,6 @@ 'setitem(a, b, c) -- Same as a[b] = c.' space.setitem(w_obj, w_key, w_value) -# setslice - def sub(space, w_a, w_b): 'sub(a, b) -- Same as a - b.' return space.sub(w_a, w_b) diff --git a/pypy/objspace/descroperation.py b/pypy/objspace/descroperation.py --- a/pypy/objspace/descroperation.py +++ b/pypy/objspace/descroperation.py @@ -322,28 +322,16 @@ return space.get_and_call_function(w_descr, w_obj, w_key) def getslice(space, w_obj, w_start, w_stop): - w_descr = space.lookup(w_obj, '__getslice__') - if w_descr is None: - w_slice = space.newslice(w_start, w_stop, space.w_None) - return space.getitem(w_obj, w_slice) - w_start, w_stop = old_slice_range(space, w_obj, w_start, w_stop) - return space.get_and_call_function(w_descr, w_obj, w_start, w_stop) + w_slice = space.newslice(w_start, w_stop, space.w_None) + return space.getitem(w_obj, w_slice) def setslice(space, w_obj, w_start, w_stop, w_sequence): - w_descr = space.lookup(w_obj, '__setslice__') - if w_descr is None: - w_slice = space.newslice(w_start, w_stop, space.w_None) - return space.setitem(w_obj, w_slice, w_sequence) - w_start, w_stop = old_slice_range(space, w_obj, w_start, w_stop) - return space.get_and_call_function(w_descr, w_obj, w_start, w_stop, w_sequence) + w_slice = space.newslice(w_start, w_stop, space.w_None) + return space.setitem(w_obj, w_slice, w_sequence) def delslice(space, w_obj, w_start, w_stop): - w_descr = space.lookup(w_obj, '__delslice__') - if w_descr is None: - w_slice = space.newslice(w_start, w_stop, space.w_None) - return space.delitem(w_obj, w_slice) - w_start, w_stop = old_slice_range(space, w_obj, w_start, w_stop) - return space.get_and_call_function(w_descr, w_obj, w_start, w_stop) + w_slice = space.newslice(w_start, w_stop, space.w_None) + return space.delitem(w_obj, w_slice) def format(space, w_obj, w_format_spec): w_descr = space.lookup(w_obj, '__format__') diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py --- a/pypy/objspace/std/listobject.py +++ b/pypy/objspace/std/listobject.py @@ -91,25 +91,6 @@ start += step return w_res -def getslice__List_ANY_ANY(space, w_list, w_start, w_stop): - length = len(w_list.wrappeditems) - start, stop = normalize_simple_slice(space, length, w_start, w_stop) - return W_ListObject(w_list.wrappeditems[start:stop]) - -def setslice__List_ANY_ANY_ANY(space, w_list, w_start, w_stop, w_sequence): - length = len(w_list.wrappeditems) - start, stop = normalize_simple_slice(space, length, w_start, w_stop) - - sequence2 = space.listview(w_sequence) - items = w_list.wrappeditems - _setitem_slice_helper(space, items, start, 1, stop-start, sequence2, - empty_elem=None) - -def delslice__List_ANY_ANY(space, w_list, w_start, w_stop): - length = len(w_list.wrappeditems) - start, stop = normalize_simple_slice(space, length, w_start, w_stop) - _delitem_slice_helper(space, w_list.wrappeditems, start, 1, stop-start) - def contains__List_ANY(space, w_list, w_obj): # needs to be safe against eq_w() mutating the w_list behind our back i = 0 diff --git a/pypy/objspace/std/rangeobject.py b/pypy/objspace/std/rangeobject.py --- a/pypy/objspace/std/rangeobject.py +++ b/pypy/objspace/std/rangeobject.py @@ -102,17 +102,6 @@ rangestep = w_rangelist.step * step return W_RangeListObject(rangestart, rangestep, slicelength) -def getslice__RangeList_ANY_ANY(space, w_rangelist, w_start, w_stop): - if w_rangelist.w_list is not None: - return space.getslice(w_rangelist.w_list, w_start, w_stop) - length = w_rangelist.length - start, stop = normalize_simple_slice(space, length, w_start, w_stop) - slicelength = stop - start - assert slicelength >= 0 - rangestart = w_rangelist.getitem_unchecked(start) - rangestep = w_rangelist.step - return W_RangeListObject(rangestart, rangestep, slicelength) - def iter__RangeList(space, w_rangelist): return W_RangeIterObject(w_rangelist) diff --git a/pypy/objspace/std/ropeobject.py b/pypy/objspace/std/ropeobject.py --- a/pypy/objspace/std/ropeobject.py +++ b/pypy/objspace/std/ropeobject.py @@ -721,15 +721,6 @@ return W_RopeObject.EMPTY return W_RopeObject(rope.getslice(node, start, stop, step, sl)) -def getslice__Rope_ANY_ANY(space, w_str, w_start, w_stop): - node = w_str._node - length = node.length() - start, stop = normalize_simple_slice(space, length, w_start, w_stop) - sl = stop - start - if sl == 0: - return W_RopeObject.EMPTY - return W_RopeObject(rope.getslice(node, start, stop, 1, sl)) - def mul_string_times(space, w_str, w_times): try: mul = space.getindex_w(w_times, space.w_OverflowError) diff --git a/pypy/objspace/std/ropeunicodeobject.py b/pypy/objspace/std/ropeunicodeobject.py --- a/pypy/objspace/std/ropeunicodeobject.py +++ b/pypy/objspace/std/ropeunicodeobject.py @@ -292,15 +292,6 @@ return W_RopeUnicodeObject.EMPTY return W_RopeUnicodeObject(rope.getslice(node, start, stop, step, sl)) -def getslice__RopeUnicode_ANY_ANY(space, w_uni, w_start, w_stop): - node = w_uni._node - length = node.length() - start, stop = normalize_simple_slice(space, length, w_start, w_stop) - sl = stop - start - if sl == 0: - return W_RopeUnicodeObject.EMPTY - return W_RopeUnicodeObject(rope.getslice(node, start, stop, 1, sl)) - def mul__RopeUnicode_ANY(space, w_uni, w_times): try: times = space.getindex_w(w_times, space.w_OverflowError) diff --git a/pypy/objspace/std/stringobject.py b/pypy/objspace/std/stringobject.py --- a/pypy/objspace/std/stringobject.py +++ b/pypy/objspace/std/stringobject.py @@ -855,14 +855,6 @@ str = "".join([s[start + i*step] for i in range(sl)]) return wrapstr(space, str) -def getslice__String_ANY_ANY(space, w_str, w_start, w_stop): - s = w_str._value - start, stop = normalize_simple_slice(space, len(s), w_start, w_stop) - if start == stop: - return W_StringObject.EMPTY - else: - return sliced(space, s, start, stop, w_str) - def mul_string_times(space, w_str, w_times): try: mul = space.getindex_w(w_times, space.w_OverflowError) diff --git a/pypy/objspace/std/strsliceobject.py b/pypy/objspace/std/strsliceobject.py --- a/pypy/objspace/std/strsliceobject.py +++ b/pypy/objspace/std/strsliceobject.py @@ -196,18 +196,6 @@ str = "".join([s[start + i*step] for i in range(sl)]) return wrapstr(space, str) -def getslice__StringSlice_ANY_ANY(space, w_str, w_start, w_stop): - length = w_str.stop - w_str.start - start, stop = normalize_simple_slice(space, length, w_start, w_stop) - sl = stop - start - if sl == 0: - return W_StringObject.EMPTY - else: - s = w_str.str - start = w_str.start + start - stop = w_str.start + stop - return W_StringSliceObject(s, start, stop) - def len__StringSlice(space, w_str): return space.wrap(w_str.stop - w_str.start) diff --git a/pypy/objspace/std/tupleobject.py b/pypy/objspace/std/tupleobject.py --- a/pypy/objspace/std/tupleobject.py +++ b/pypy/objspace/std/tupleobject.py @@ -58,11 +58,6 @@ start += step return space.newtuple(subitems) -def getslice__Tuple_ANY_ANY(space, w_tuple, w_start, w_stop): - length = len(w_tuple.wrappeditems) - start, stop = normalize_simple_slice(space, length, w_start, w_stop) - return space.newtuple(w_tuple.wrappeditems[start:stop]) - def contains__Tuple_ANY(space, w_tuple, w_obj): for w_item in w_tuple.wrappeditems: if space.eq_w(w_item, w_obj): 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 @@ -260,11 +260,6 @@ r = u"".join([uni[start + i*step] for i in range(sl)]) return W_UnicodeObject(r) -def getslice__Unicode_ANY_ANY(space, w_uni, w_start, w_stop): - uni = w_uni._value - start, stop = normalize_simple_slice(space, len(uni), w_start, w_stop) - return W_UnicodeObject(uni[start:stop]) - def mul__Unicode_ANY(space, w_uni, w_times): try: times = space.getindex_w(w_times, space.w_OverflowError) diff --git a/pypy/objspace/test/test_descroperation.py b/pypy/objspace/test/test_descroperation.py --- a/pypy/objspace/test/test_descroperation.py +++ b/pypy/objspace/test/test_descroperation.py @@ -127,10 +127,9 @@ def test_getslice(self): class Sq(object): - def __getslice__(self, start, stop): + def __getitem__(self, key): + start, stop = key return (start, stop) - def __getitem__(self, key): - return "booh" def __len__(self): return 100 @@ -152,10 +151,9 @@ def test_setslice(self): class Sq(object): - def __setslice__(self, start, stop, sequence): - ops.append((start, stop, sequence)) def __setitem__(self, key, value): - raise AssertionError, key + start, stop = key + ops.append((start, stop, value)) def __len__(self): return 100 @@ -177,10 +175,9 @@ def test_delslice(self): class Sq(object): - def __delslice__(self, start, stop): + def __delitem__(self, key): + start, stop = key ops.append((start, stop)) - def __delitem__(self, key): - raise AssertionError, key def __len__(self): return 100 @@ -202,10 +199,9 @@ def test_getslice_nolength(self): class Sq(object): - def __getslice__(self, start, stop): + def __getitem__(self, key): + start, stop = key return (start, stop) - def __getitem__(self, key): - return "booh" sq = Sq() _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit