summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2011-05-05 21:34:35 (GMT)
committerRaymond Hettinger <python@rcn.com>2011-05-05 21:34:35 (GMT)
commit1c7b7f7fbeb79eaddcd21b20a43802db0f7790a1 (patch)
tree57bdef35d8520e3ca1d9e8f3b7286b05e488d117 /Lib
parent7b48432a77c9a3e902e28fa654882f04c38423fd (diff)
downloadcpython-1c7b7f7fbeb79eaddcd21b20a43802db0f7790a1.zip
cpython-1c7b7f7fbeb79eaddcd21b20a43802db0f7790a1.tar.gz
cpython-1c7b7f7fbeb79eaddcd21b20a43802db0f7790a1.tar.bz2
Userlist.copy() wasn't returning a UserList.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/collections/__init__.py2
-rw-r--r--Lib/test/test_userlist.py6
2 files changed, 7 insertions, 1 deletions
diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py
index 53e3dd7..4b447ac 100644
--- a/Lib/collections/__init__.py
+++ b/Lib/collections/__init__.py
@@ -887,7 +887,7 @@ class UserList(MutableSequence):
def pop(self, i=-1): return self.data.pop(i)
def remove(self, item): self.data.remove(item)
def clear(self): self.data.clear()
- def copy(self): return self.data.copy()
+ def copy(self): return self.__class__(self)
def count(self, item): return self.data.count(item)
def index(self, item, *args): return self.data.index(item, *args)
def reverse(self): self.data.reverse()
diff --git a/Lib/test/test_userlist.py b/Lib/test/test_userlist.py
index 868ed24..6381070 100644
--- a/Lib/test/test_userlist.py
+++ b/Lib/test/test_userlist.py
@@ -52,6 +52,12 @@ class UserListTest(list_tests.CommonTest):
return str(key) + '!!!'
self.assertEqual(next(iter(T((1,2)))), "0!!!")
+ def test_userlist_copy(self):
+ u = self.type2test([6, 8, 1, 9, 1])
+ v = u.copy()
+ self.assertEqual(u, v)
+ self.assertEqual(type(u), type(v))
+
def test_main():
support.run_unittest(UserListTest)