Author serhiy.storchaka
Recipients nadeem.vawda, serhiy.storchaka
Date 2016-09-27.14:01:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1474984904.89.0.353695342219.issue28286@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2016-09-27 14:01:44serhiy.storchakasetrecipients: + serhiy.storchaka, nadeem.vawda
2016-09-27 14:01:44serhiy.storchakasetmessageid: <1474984904.89.0.353695342219.issue28286@psf.upfronthosting.co.za>
2016-09-27 14:01:44serhiy.storchakalinkissue28286 messages
2016-09-27 14:01:44serhiy.storchakacreate