diff options
author | Nadeem Vawda <nadeem.vawda@gmail.com> | 2012-10-01 21:02:50 (GMT) |
---|---|---|
committer | Nadeem Vawda <nadeem.vawda@gmail.com> | 2012-10-01 21:02:50 (GMT) |
commit | 452add08a186a09f346a28306c96f4c89bf93c9e (patch) | |
tree | f7e3f3f6a0e9265753427fe67919112f445a2451 /Lib/bz2.py | |
parent | 4524b467338812b69da5783f4b5d38d02a5436b0 (diff) | |
download | cpython-452add08a186a09f346a28306c96f4c89bf93c9e.zip cpython-452add08a186a09f346a28306c96f4c89bf93c9e.tar.gz cpython-452add08a186a09f346a28306c96f4c89bf93c9e.tar.bz2 |
Issue #16304: Another performance optimization for BZ2File.
Patch by Serhiy Storchaka.
Diffstat (limited to 'Lib/bz2.py')
-rw-r--r-- | Lib/bz2.py | 9 |
1 files changed, 3 insertions, 6 deletions
@@ -159,21 +159,18 @@ class BZ2File(io.BufferedIOBase): raise ValueError("I/O operation on closed file") def _check_can_read(self): - if self.closed: - raise ValueError("I/O operation on closed file") if self._mode not in (_MODE_READ, _MODE_READ_EOF): + self._check_not_closed() raise io.UnsupportedOperation("File not open for reading") def _check_can_write(self): - if self.closed: - raise ValueError("I/O operation on closed file") if self._mode != _MODE_WRITE: + self._check_not_closed() raise io.UnsupportedOperation("File not open for writing") def _check_can_seek(self): - if self.closed: - raise ValueError("I/O operation on closed file") if self._mode not in (_MODE_READ, _MODE_READ_EOF): + self._check_not_closed() raise io.UnsupportedOperation("Seeking is only supported " "on files open for reading") if not self._fp.seekable(): |