classification
Title: gzip guessing of mode is ambiguous
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: nadeem.vawda, serhiy.storchaka, wolma
Priority: normal Keywords: patch

Created on 2016-09-27 14:01 by serhiy.storchaka, last changed 2019-11-16 17:22 by serhiy.storchaka. This issue is now closed.

Files
File name Uploaded Description Edit
gzip_deprecate_implicit_write.patch serhiy.storchaka, 2016-09-27 14:01 review
gzip_deprecate_implicit_write2.patch serhiy.storchaka, 2016-10-02 17:55 review
Pull Requests
URL Status Linked Edit
PR 4074 merged serhiy.storchaka, 2017-10-22 09:37
PR 4076 merged python-dev, 2017-10-22 10:18
PR 4077 merged serhiy.storchaka, 2017-10-22 10:43
PR 16417 merged serhiy.storchaka, 2019-09-26 09:17
Messages (6)
msg277515 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-09-27 14:01
gzip.GzipFile can be open in two modes: reading and writing. The mode is specified by the mode parameter, but if it is not specified or is None, the mode is determined by the mode of passed file object. The problem is that the file object can support reading and writing. If the file object is opened with mode "rb", "rb+" or "wb+" (see also issue25341), GzipFile will be opened for reading. If the file object is opened with mode "wb", "ab", "ab+", "xb", or "xb+", GzipFile will be opened for writing. Modes "rb+", "wb+", "ab+" and "xb+" support reading and writing, and GzipFile's choose looks arbitrary.

bz2 and lzma are free from this arbitrariness. The default value of the mode parameter is "r", and they never use file's mode as a guess.

This feature of the gzip module is not tested. Changing the default value of mode to "r" doesn't break gzip tests. But for certainty we should first deprecate this feature before dropping it.
msg277907 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-10-02 17:55
Or maybe FutureWarning is better than DeprecationWarning.
msg304739 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-10-22 10:18
New changeset bcbdd2f8db396c3f0ec9186162b39b5a34effa0e by Serhiy Storchaka in branch 'master':
bpo-28286: Add tests for the mode argument of GzipFile. (#4074)
https://github.com/python/cpython/commit/bcbdd2f8db396c3f0ec9186162b39b5a34effa0e
msg304743 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-10-22 11:53
New changeset 251de30935490a702b0a365f1e9bea696b39c016 by Serhiy Storchaka (Miss Islington (bot)) in branch '3.6':
bpo-28286: Add tests for the mode argument of GzipFile. (GH-4074) (#4076)
https://github.com/python/cpython/commit/251de30935490a702b0a365f1e9bea696b39c016
msg304744 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-10-22 11:54
New changeset f7d19b0464cb89ec696affbad9fd7e7c94456eaf by Serhiy Storchaka in branch '2.7':
[2.7] bpo-28286: Add tests for the mode argument of GzipFile. (GH-4074). (#4077)
https://github.com/python/cpython/commit/f7d19b0464cb89ec696affbad9fd7e7c94456eaf
msg356756 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-11-16 16:57
New changeset a0652328a26757a90d63697b5c01f5427b1132b5 by Serhiy Storchaka in branch 'master':
bpo-28286: Deprecate opening GzipFile for writing implicitly. (GH-16417)
https://github.com/python/cpython/commit/a0652328a26757a90d63697b5c01f5427b1132b5
History
Date User Action Args
2019-11-16 17:22:24serhiy.storchakasetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: + Python 3.9, - Python 3.7
2019-11-16 16:57:00serhiy.storchakasetmessages: + msg356756
2019-09-26 09:17:50serhiy.storchakasetpull_requests: + pull_request15997
2017-10-22 20:19:14wolmasetnosy: + wolma
2017-10-22 11:54:07serhiy.storchakasetmessages: + msg304744
2017-10-22 11:53:46serhiy.storchakasetmessages: + msg304743
2017-10-22 10:43:34serhiy.storchakasetpull_requests: + pull_request4047
2017-10-22 10:18:30python-devsetpull_requests: + pull_request4046
2017-10-22 10:18:23serhiy.storchakasetmessages: + msg304739
2017-10-22 09:37:32serhiy.storchakasetpull_requests: + pull_request4044
2016-10-03 16:58:36Jim.Jewettsettitle: gzip guessing of mode is ambiguilous -> gzip guessing of mode is ambiguous
2016-10-02 17:55:42serhiy.storchakasetfiles: + gzip_deprecate_implicit_write2.patch

messages: + msg277907
2016-09-27 14:01:44serhiy.storchakacreate