diff options
| author | R David Murray <rdmurray@bitdance.com> | 2011-06-18 02:25:14 (GMT) |
|---|---|---|
| committer | R David Murray <rdmurray@bitdance.com> | 2011-06-18 02:25:14 (GMT) |
| commit | 953510560f5443f15f3a3d3099b102ad7764909a (patch) | |
| tree | f4557140c14d10c1f9e61d7cb8c9ce93fce942b4 /Lib/mailbox.py | |
| parent | 85198753f16a6f81ad43223a65adddaf50e14fad (diff) | |
| parent | c88bce1580c61ee33bf72e55b817940dba46d99c (diff) | |
| download | cpython-953510560f5443f15f3a3d3099b102ad7764909a.zip cpython-953510560f5443f15f3a3d3099b102ad7764909a.tar.gz cpython-953510560f5443f15f3a3d3099b102ad7764909a.tar.bz2 | |
merge #11700: proxy object close methods can now be called multiple times
Diffstat (limited to 'Lib/mailbox.py')
| -rw-r--r-- | Lib/mailbox.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Lib/mailbox.py b/Lib/mailbox.py index b96b270..e23ea8c 100644 --- a/Lib/mailbox.py +++ b/Lib/mailbox.py @@ -1923,9 +1923,10 @@ class _ProxyFile: def close(self): """Close the file.""" - if hasattr(self._file, 'close'): - self._file.close() - del self._file + if hasattr(self, '_file'): + if hasattr(self._file, 'close'): + self._file.close() + del self._file def _read(self, size, read_method): """Read size bytes using read_method.""" @@ -1957,6 +1958,10 @@ class _ProxyFile: @property def closed(self): + if not hasattr(self, '_file'): + return True + if not hasattr(self._file, 'closed'): + return False return self._file.closed @@ -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 - del self._file + if hasattr(self, '_file'): + del self._file def _lock_file(f, dotlock=True): |
