Nadeem Vawda <nadeem.va...@gmail.com> added the comment: 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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue13989> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com