summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2000-10-06 19:26:01 (GMT)
committerFred Drake <fdrake@acm.org>2000-10-06 19:26:01 (GMT)
commitcc773d3b11967b36684b0681e54ed6388bf7370c (patch)
treed97a4d2aa0ab9b7c3bbc61b1ab0dc52b9b5dfbf4 /Lib
parente60de4d30984b6d551cda0515fb76ac02d547415 (diff)
downloadcpython-cc773d3b11967b36684b0681e54ed6388bf7370c.zip
cpython-cc773d3b11967b36684b0681e54ed6388bf7370c.tar.gz
cpython-cc773d3b11967b36684b0681e54ed6388bf7370c.tar.bz2
__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.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/UserList.py4
1 files changed, 1 insertions, 3 deletions
diff --git a/Lib/UserList.py b/Lib/UserList.py
index aab5119..e79faea 100644
--- a/Lib/UserList.py
+++ b/Lib/UserList.py
@@ -24,9 +24,7 @@ class UserList:
def __delitem__(self, i): del self.data[i]
def __getslice__(self, i, j):
i = max(i, 0); j = max(j, 0)
- userlist = self.__class__()
- userlist.data[:] = self.data[i:j]
- return userlist
+ return self.__class__(self.data[i:j])
def __setslice__(self, i, j, other):
i = max(i, 0); j = max(j, 0)
if isinstance(other, UserList):