mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
Fix seekable() in BZ2File and LZMAFile to check whether the underlying file supports seek().
This commit is contained in:
parent
d7e5c6ed7f
commit
ae557d767f
4 changed files with 28 additions and 4 deletions
|
|
@ -165,7 +165,7 @@ class LZMAFile(io.BufferedIOBase):
|
|||
|
||||
def seekable(self):
|
||||
"""Return whether the file supports seeking."""
|
||||
return self.readable()
|
||||
return self.readable() and self._fp.seekable()
|
||||
|
||||
def readable(self):
|
||||
"""Return whether the file was opened for reading."""
|
||||
|
|
@ -192,9 +192,12 @@ class LZMAFile(io.BufferedIOBase):
|
|||
raise io.UnsupportedOperation("File not open for writing")
|
||||
|
||||
def _check_can_seek(self):
|
||||
if not self.seekable():
|
||||
if not self.readable():
|
||||
raise io.UnsupportedOperation("Seeking is only supported "
|
||||
"on files open for reading")
|
||||
if not self._fp.seekable():
|
||||
raise io.UnsupportedOperation("The underlying file object "
|
||||
"does not support seeking")
|
||||
|
||||
# Fill the readahead buffer if it is empty. Returns False on EOF.
|
||||
def _fill_buffer(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue