[Python-bugs-list] [ python-Bugs-442705 ] 2.2a1: Overriding __setslice__
noreply@sourceforge.net
noreply@sourceforge.net
Thu, 19 Jul 2001 05:43:38 -0700
Bugs item #442705, was opened at 2001-07-19 03:31
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=442705&group_id=5470
>Category: type/class unification
>Group: Python 2.2
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Walter Dörwald (doerwalter)
Assigned to: Guido van Rossum (gvanrossum)
>Summary: 2.2a1: Overriding __setslice__
Initial Comment:
Overwriting list.__setslice__ in derived
classes doesn't seem to work in 2.2a1:
----
class C(list):
def __setslice__(*args):
list.__setslice__(*args)
c = list((1,2,3,4))
c[1:3] = [5, 6]
print c
c = C((1,2,3,4))
c[1:3] = [5, 6]
print c
----
Output:
[1, 5, 6, 4]
Traceback (most recent call last):
File "test.py", line 10, in ?
c[1:3] = [5, 6]
TypeError: function takes exactly 2 arguments (3 given)
----------------------------------------------------------------------
>Comment By: Guido van Rossum (gvanrossum)
Date: 2001-07-19 05:43
Message:
Logged In: YES
user_id=6380
You're right! To fix: in file typeobject.c, function
slot_sq_ass_slice(), change "__setitem__" to
"__setslice__". Then all will be fine.
Fixed in CVS, typeobject.c:2.16.8.68.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=442705&group_id=5470