Issue #5148: Ignore 'U' in mode given to gzip.open() and gzip.GzipFile().

This commit is contained in:
Nadeem Vawda 2012-10-21 18:15:05 +02:00
parent c30848344c
commit dd72b3f6b7
3 changed files with 13 additions and 0 deletions

View file

@ -81,6 +81,10 @@ class GzipFile(io.BufferedIOBase):
"""
# Make sure we don't inadvertently enable universal newlines on the
# underlying file object - in read mode, this causes data corruption.
if mode:
mode = mode.replace('U', '')
# guarantee the file is opened in binary mode on platforms
# that care about that sort of thing
if mode and 'b' not in mode: