[issue30012] gzip.open(filename, "rt") fails on Python 2.7.11 on win32, invalid mode rtb

Peter report at bugs.python.org
Fri Apr 7 16:53:42 EDT 2017


Peter added the comment:

I want a simple cross platform (Linux/Mac/Windows) and cross version (Python 2/3) way to be able to open a gzipped file and get a string handle (default encoding TextIOWrapper under Python 3 is fine). My use-case is specifically for documentation examples.

Previously I used gzip.open(filename) but with the introduction of Python 3 that stopped working because the Python 3 default was to give you bytes.

Thanks to http://bugs.python.org/issue13989 switching to  gzip.open(filename, "rt") almost covered my use case, leaving Python 2 windows as the odd one out.

I propose that under Python 2.7, gzip.open explicit accept but ignore "t" as part of the mode argument in order to allow cross-platform code to work nicely.

i.e. Formalise the observed Python 2.7 behaviour under Linux and Mac which ignore the "t", and change Windows so that it ignores the "t" as well.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30012>
_______________________________________


More information about the Python-bugs-list mailing list