cpython: 8319db2dd342 (original) (raw)

Mercurial > cpython

changeset 70857:8319db2dd342 3.2

#11700: proxy object close methods can now be called multiple times This makes them work like the close provided by regular file objects. [#11700]

R David Murray rdmurray@bitdance.com
date Fri, 17 Jun 2011 22:24:05 -0400
parents fea1920ae75f
children 0705b9037b20 d62e5682a8ac
files Lib/mailbox.py Lib/test/test_mailbox.py Misc/NEWS
diffstat 3 files changed, 25 insertions(+), 5 deletions(-)[+] [-] Lib/mailbox.py 14 Lib/test/test_mailbox.py 13 Misc/NEWS 3

line wrap: on

line diff

--- a/Lib/mailbox.py +++ b/Lib/mailbox.py @@ -1923,9 +1923,10 @@ class _ProxyFile: def close(self): """Close the file."""

def _read(self, size, read_method): """Read size bytes using read_method.""" @@ -1957,6 +1958,10 @@ class _ProxyFile: @property def closed(self):

@@ -1995,7 +2000,8 @@ class _PartialFile(_ProxyFile): def close(self): # do not close the underlying file object for partial files, # since it's global to the mailbox object

def _lock_file(f, dotlock=True):

--- a/Lib/test/test_mailbox.py +++ b/Lib/test/test_mailbox.py @@ -297,6 +297,13 @@ class TestMailbox(TestBase): self.assertEqual(data1.decode('ascii').replace(os.linesep, '\n'), _sample_message)

+ def test_iterkeys(self): # Get keys using iterkeys() self._check_iteration(self._box.keys, do_keys=True, do_values=False) @@ -1862,8 +1869,12 @@ class TestProxyFileBase(TestBase): def _test_close(self, proxy): # Close a file

class TestProxyFile(TestProxyFileBase):

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -25,6 +25,9 @@ Core and Builtins Library ------- +- Issue #11700: mailbox proxy object close methods can now be called multiple