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 nadeem.vawda
Recipients maubp, nadeem.vawda
Date 2012-02-11.13:55:56
SpamBayes Score 6.7281873e-09
Marked as misclassified No
Message-id <1328968556.95.0.350896733783.issue13989@psf.upfronthosting.co.za>
In-reply-to
Content
The problem here is that gzip.GzipFile does not support text mode, only
binary mode. Unfortunately, its __init__ method doesn't handle unexpected
mode strings sensibly, so you get a confusing error message.

If you need to open a compressed file in text mode in Python 3.2, use
io.TextIOWrapper:

    with io.TextIOWrapper(gzip.open("ex1.sam.gz", "r")) as f:
        line = f.readline()

In 3.3, it would be nice for gzip.open to do this transparently when mode
is "rt"/"wt"/"at". However, binary mode will still need to be the default
(for modes "r", "w" and "a"), to ensure backward compatibility.

In the meanwhile, I'll add a note to the documentation about this
limitation, and fix GzipFile.__init__ to produce a more sensible error
message.
History
Date User Action Args
2012-02-11 13:55:57nadeem.vawdasetrecipients: + nadeem.vawda, maubp
2012-02-11 13:55:56nadeem.vawdasetmessageid: <1328968556.95.0.350896733783.issue13989@psf.upfronthosting.co.za>
2012-02-11 13:55:56nadeem.vawdalinkissue13989 messages
2012-02-11 13:55:56nadeem.vawdacreate