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 __starrify__
Recipients __starrify__
Date 2019-09-26.00:49:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1569458951.07.0.462687490568.issue38281@roundup.psfhosted.org>
In-reply-to
Content
Currently (as of df69e75) it checks only the initial letter (via `mode.startswith`) of "mode" in gzip.GzipFile.__init__. See also: https://github.com/python/cpython/blob/df69e75/Lib/gzip.py#L183

I'd personally suggest that it takes also "+" into consideration, which shall be regarded as writable.

One common (hm.. at least I've observed more than once recently) case where people may make mistakes is to use a tempfile.NamedTemporaryFile as the file object without specifying explicitly a mode, while expecting the GzipFile to be writable.

A quick example (in Python 3.7.11):
```
>>> import tempfile
>>> tempfile.NamedTemporaryFile().mode
'rb+'
>>> import gzip
>>> gzip.GzipFile(fileobj=tempfile.NamedTemporaryFile(mode='rb+')).writable()
False
>>> gzip.GzipFile(fileobj=tempfile.NamedTemporaryFile(mode='wb')).writable()
True
```

Unfortunately this change request may be backward-incompatible, since previously modes like "r+b" have been treated as read-only. See also: https://github.com/python/cpython/blob/df69e75/Lib/test/test_gzip.py#L464
History
Date User Action Args
2019-09-26 00:49:11__starrify__setrecipients: + __starrify__
2019-09-26 00:49:11__starrify__setmessageid: <1569458951.07.0.462687490568.issue38281@roundup.psfhosted.org>
2019-09-26 00:49:11__starrify__linkissue38281 messages
2019-09-26 00:49:10__starrify__create