[Python-bugs-list] [ python-Bugs-408308 ] UserList.py bug in getslice, *add, mul

nobody nobody@sourceforge.net
Tue, 13 Mar 2001 12:00:13 -0800


Bugs #408308, was updated on 2001-03-13 12:00
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=408308&group_id=5470

Category: Python Library
Group: None
Status: Open
Priority: 5
Submitted By: Daniel Haertle
Assigned to: Nobody/Anonymous
Summary: UserList.py bug in getslice, *add, mul 

Initial Comment:
if one explitely initializes UserList in a class derived 
form Userlist, __getslice__, __*add__ and __mul__ do not 
work.

Consider the following code:

>>> import UserList
>>> class UL(UserList.UserList):
...    def __init__(self):
...       UserList.UserList.__init__(self)
... 
>>> ul=UL()
>>> ul.append(0); ul.append(1)
>>> ul[0:2]
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "hd e18 yosi:programs:programing:python 
2.0c1:lib:UserList.py", line 27, in __getslice__
    return self.__class__(self.data[i:j])
TypeError: too many arguments; expected 1, got 2


A possible solution is to change UserList.py from

    def __getslice__(self, i, j):
        i = max(i, 0); j = max(j, 0)
        return self.__class__(self.data[i:j])

to

    def __getslice__(self, i, j):
        i = max(i, 0); j = max(j, 0)
        return self.data[i:j]

and the other methods accordingly. If for some reasons 
this is not possible, consider the code in Python1.5.2 
where __getslice__ works (but __*add__ and __mul__ 
don't)


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=408308&group_id=5470