Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/gzip.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def writable(self):
return self.mode == WRITE

def seekable(self):
return True
return self.fileobj.seekable()

def seek(self, offset, whence=io.SEEK_SET):
if self.mode == WRITE:
Expand Down
8 changes: 8 additions & 0 deletions Lib/test/test_gzip.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,14 @@ def test_prepend_error(self):
with gzip.open(self.filename, "rb") as f:
f._buffer.raw._fp.prepend()

def test_seekable(self):
seekable = gzip.GzipFile(fileobj=io.BytesIO())
not_seekable = gzip.GzipFile(fileobj=UnseekableIO())

self.assertTrue(seekable.seekable())
self.assertFalse(not_seekable.seekable())


class TestOpen(BaseTest):
def test_binary_modes(self):
uncompressed = data1 * 50
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
gzip.GzipFile's seekable() method returns the seek-ability of its underlying
file object