1. Pypy
  2. Untitled project
  3. pypy

Commits

Amaury Forgeot d'Arc  committed 459148c

Remove all references to the __getslice__ methods and opcodes
space.getslice() still exists, and delegates to getitem.

  • Participants
  • Parent commits 4f33a53
  • Branches py3k

Comments (0)

Files changed (23)

File pypy/interpreter/astcompiler/codegen.py

View file
  • Ignore whitespace
     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):
 
         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)
                 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"

File pypy/interpreter/baseobjspace.py

View file
  • Ignore whitespace
     ('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__']),

File pypy/interpreter/pyopcode.py

View file
  • Ignore whitespace
     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()

File pypy/module/__builtin__/interp_classobj.py

View file
  • Ignore whitespace
     #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__)
     __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),

File pypy/module/__builtin__/test/test_classobj.py

View file
  • Ignore whitespace
             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):

File pypy/module/array/interp_array.py

View file
  • Ignore whitespace
             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:
                     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)
         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):

File pypy/module/array/test/test_array.py

View file
  • Ignore whitespace
         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])
         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

File pypy/module/cpyext/include/object.h

View file
  • Ignore whitespace
 	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;

File pypy/module/cpyext/slotdefs.py

View file
  • Ignore whitespace
           "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,

File pypy/module/cpyext/typeobjectdefs.py

View file
  • Ignore whitespace
     ("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),

File pypy/module/operator/__init__.py

View file
  • Ignore whitespace
 
     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:

File pypy/module/operator/app_operator.py

View file
  • Ignore whitespace
             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
 
 __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:

File pypy/module/operator/interp_operator.py

View file
  • Ignore whitespace
     '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)
     '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)
     '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.'
     '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) 

File pypy/objspace/descroperation.py

View file
  • Ignore whitespace
         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__')

File pypy/objspace/std/listobject.py

View file
  • Ignore whitespace
         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

File pypy/objspace/std/rangeobject.py

View file
  • Ignore whitespace
     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)
 

File pypy/objspace/std/ropeobject.py

View file
  • Ignore whitespace
         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)

File pypy/objspace/std/ropeunicodeobject.py

View file
  • Ignore whitespace
         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)

File pypy/objspace/std/stringobject.py

View file
  • Ignore whitespace
         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)

File pypy/objspace/std/strsliceobject.py

View file
  • Ignore whitespace
             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)
 

File pypy/objspace/std/tupleobject.py

View file
  • Ignore whitespace
         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):

File pypy/objspace/std/unicodeobject.py

View file
  • Ignore whitespace
         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)

File pypy/objspace/test/test_descroperation.py

View file
  • Ignore whitespace
 
     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
 
 
     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
 
 
     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
 
 
     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()