From: Eli Bendersky Date: Fri, 4 Mar 2011 05:34:58 +0000 (+0000) Subject: Issue #11388: Added a clear() method to MutableSequence X-Git-Tag: v3.3.0a1~2996 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9479d1ade84d7a386a107989b699fb90b73cfa15;p=thirdparty%2FPython%2Fcpython.git Issue #11388: Added a clear() method to MutableSequence --- diff --git a/Lib/collections/abc.py b/Lib/collections/abc.py index 6e908bdce973..c80c7ddd4430 100644 --- a/Lib/collections/abc.py +++ b/Lib/collections/abc.py @@ -596,6 +596,13 @@ class MutableSequence(Sequence): def append(self, value): self.insert(len(self), value) + def clear(self): + try: + while True: + self.pop() + except IndexError: + pass + def reverse(self): n = len(self) for i in range(n//2): diff --git a/Misc/NEWS b/Misc/NEWS index 876afdd08ef3..6b484f727c90 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -140,6 +140,8 @@ Library - Issue #10276: Fix the results of zlib.crc32() and zlib.adler32() on buffers larger than 4GB. Patch by Nadeem Vawda. +- Issue #11388: Added a clear() method to MutableSequence + Build -----