mirror of https://github.com/python/cpython.git
__getslice__(): Make this use the constructor form that gets a sequence
as a parameter; this was the only use of the base constructor or surgical alteration of another object's data attribute. This change simplifies the constructor requirements for subclasses. This relates to SourceForge bug #115928.
This commit is contained in:
parent
e60de4d309
commit
cc773d3b11
|
@ -24,9 +24,7 @@ def __setitem__(self, i, item): self.data[i] = item
|
||||||
def __delitem__(self, i): del self.data[i]
|
def __delitem__(self, i): del self.data[i]
|
||||||
def __getslice__(self, i, j):
|
def __getslice__(self, i, j):
|
||||||
i = max(i, 0); j = max(j, 0)
|
i = max(i, 0); j = max(j, 0)
|
||||||
userlist = self.__class__()
|
return self.__class__(self.data[i:j])
|
||||||
userlist.data[:] = self.data[i:j]
|
|
||||||
return userlist
|
|
||||||
def __setslice__(self, i, j, other):
|
def __setslice__(self, i, j, other):
|
||||||
i = max(i, 0); j = max(j, 0)
|
i = max(i, 0); j = max(j, 0)
|
||||||
if isinstance(other, UserList):
|
if isinstance(other, UserList):
|
||||||
|
|
Loading…
Reference in New Issue