[Python-Dev] [Python-checkins] cpython: Userlist.copy() wasn't returning a UserList. (original) (raw)
Jim Jewett jimjjewett at gmail.com
Fri May 6 15:49:19 CEST 2011
- Previous message: [Python-Dev] cpython (merge 3.2 -> default): Avoid codec spelling issues by just using the utf-8 default.
- Next message: [Python-Dev] Linus on garbage collection
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Do you also want to assert that u is not v, or would that sort of "copy" be acceptable by some subclasses?
On 5/5/11, raymond.hettinger <python-checkins at python.org> wrote:
http://hg.python.org/cpython/rev/f20373fcdde5 changeset: 69865:f20373fcdde5 user: Raymond Hettinger <python at rcn.com> date: Thu May 05 14:34:35 2011 -0700 summary: Userlist.copy() wasn't returning a UserList.
files: Lib/collections/init.py | 2 +- Lib/test/testuserlist.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/Lib/collections/init.py b/Lib/collections/init.py --- a/Lib/collections/init.py +++ b/Lib/collections/init.py @@ -887,7 +887,7 @@ 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/testuserlist.py b/Lib/test/testuserlist.py --- a/Lib/test/testuserlist.py +++ b/Lib/test/testuserlist.py @@ -52,6 +52,12 @@ return str(key) + '!!!' self.assertEqual(next(iter(T((1,2)))), "0!!!") + def testuserlistcopy(self): + u = self.type2test([6, 8, 1, 9, 1]) + v = u.copy() + self.assertEqual(u, v) + self.assertEqual(type(u), type(v)) + def testmain(): support.rununittest(UserListTest) -- Repository URL: http://hg.python.org/cpython
- Previous message: [Python-Dev] cpython (merge 3.2 -> default): Avoid codec spelling issues by just using the utf-8 default.
- Next message: [Python-Dev] Linus on garbage collection
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]