New submission from Serhiy Storchaka:

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.

----------
components: Library (Lib)
files: gzip_deprecate_implicit_write.patch
keywords: patch
messages: 277515
nosy: nadeem.vawda, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: gzip guessing of mode is ambiguilous
type: enhancement
versions: Python 3.7
Added file: http://bugs.python.org/file44843/gzip_deprecate_implicit_write.patch

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

Reply via email to