This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Walt Askew
Recipients Walt Askew
Date 2018-03-28.16:28:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1522254528.0.0.467229070634.issue33173@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-03-28 16:28:48Walt Askewsetrecipients: + Walt Askew
2018-03-28 16:28:48Walt Askewsetmessageid: <1522254528.0.0.467229070634.issue33173@psf.upfronthosting.co.za>
2018-03-28 16:28:47Walt Askewlinkissue33173 messages
2018-03-28 16:28:47Walt Askewcreate