Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
dd72b3f6
Commit
dd72b3f6
authored
Oct 21, 2012
by
Nadeem Vawda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #5148: Ignore 'U' in mode given to gzip.open() and gzip.GzipFile().
parent
c3084834
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
0 deletions
+13
-0
Lib/gzip.py
Lib/gzip.py
+4
-0
Lib/test/test_gzip.py
Lib/test/test_gzip.py
+7
-0
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/gzip.py
View file @
dd72b3f6
...
...
@@ -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
:
...
...
Lib/test/test_gzip.py
View file @
dd72b3f6
...
...
@@ -53,6 +53,13 @@ class TestGzip(unittest.TestCase):
d
=
f
.
read
()
self
.
assertEqual
(
d
,
data1
*
50
)
def
test_read_universal_newlines
(
self
):
# Issue #5148: Reading breaks when mode contains 'U'.
self
.
test_write
()
with
gzip
.
GzipFile
(
self
.
filename
,
'rU'
)
as
f
:
d
=
f
.
read
()
self
.
assertEqual
(
d
,
data1
*
50
)
def
test_io_on_closed_object
(
self
):
# Test that I/O operations on closed GzipFile objects raise a
# ValueError, just like the corresponding functions on file objects.
...
...
Misc/NEWS
View file @
dd72b3f6
...
...
@@ -122,6 +122,8 @@ Core and Builtins
Library
-------
-
Issue
#
5148
:
Ignore
'U'
in
mode
given
to
gzip
.
open
()
and
gzip
.
GzipFile
().
-
Issue
#
16220
:
wsgiref
now
always
calls
close
()
on
an
iterable
response
.
Patch
by
Brent
Tubbs
.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment