New submission from Walt Askew <waltas...@gmail.com>:

The seekable method on gzip.GzipFile always returns True, even if the 
underlying buffer is not seekable. However, if seek is called on the GzipFile, 
the seek will fail unless the underlying buffer is seekable. This can cause 
consumers of the GzipFile object to mistakenly believe calling seek on the 
object is safe, when in fact it will lead to an exception.

For example, this led to a bug when I was trying to use requests & boto3 to 
stream & decompress an S3 upload like so:

resp = requests.get(uri, stream=True)
decompressed = gzip.GzipFile(fileobj=resp.raw)
boto3.client('s3').upload_fileobj(decompressed, Bucket=bucket, Key=key)

boto3 checks the seekable method on the the GzipFile, chooses a code path based 
on the file being seekable but later raises an exception when the seek call 
fails because the underlying HTTP stream is not seekable.

----------
components: Library (Lib)
messages: 314613
nosy: Walt Askew
priority: normal
severity: normal
status: open
title: GzipFile's .seekable() returns True even if underlying buffer is not 
seekable
versions: Python 3.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33173>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to