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
7e69f008
Commit
7e69f008
authored
Apr 08, 2013
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Close #17666: Fix reading gzip files with an extra field.
parent
b0f9fa7a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
1 deletion
+11
-1
Lib/gzip.py
Lib/gzip.py
+2
-1
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 @
7e69f008
...
@@ -302,7 +302,8 @@ class GzipFile(io.BufferedIOBase):
...
@@ -302,7 +302,8 @@ class GzipFile(io.BufferedIOBase):
if
flag
&
FEXTRA
:
if
flag
&
FEXTRA
:
# Read & discard the extra field, if present
# Read & discard the extra field, if present
self
.
_read_exact
(
struct
.
unpack
(
"<H"
,
self
.
_read_exact
(
2
)))
extra_len
,
=
struct
.
unpack
(
"<H"
,
self
.
_read_exact
(
2
))
self
.
_read_exact
(
extra_len
)
if
flag
&
FNAME
:
if
flag
&
FNAME
:
# Read and discard a null-terminated string containing the filename
# Read and discard a null-terminated string containing the filename
while
True
:
while
True
:
...
...
Lib/test/test_gzip.py
View file @
7e69f008
...
@@ -403,6 +403,13 @@ class TestGzip(BaseTest):
...
@@ -403,6 +403,13 @@ class TestGzip(BaseTest):
with
gzip
.
GzipFile
(
fileobj
=
io
.
BytesIO
(
truncated
[:
i
]))
as
f
:
with
gzip
.
GzipFile
(
fileobj
=
io
.
BytesIO
(
truncated
[:
i
]))
as
f
:
self
.
assertRaises
(
EOFError
,
f
.
read
,
1
)
self
.
assertRaises
(
EOFError
,
f
.
read
,
1
)
def
test_read_with_extra
(
self
):
# Gzip data with an extra field
gzdata
=
(
b'
\
x1f
\
x8b
\
x08
\
x04
\
xb2
\
x17
cQ
\
x02
\
xff
'
b'
\
x05
\
x00
Extra'
b'
\
x0b
I-.
\
x01
\
x00
2
\
xd1
Mx
\
x04
\
x00
\
x00
\
x00
'
)
with
gzip
.
GzipFile
(
fileobj
=
io
.
BytesIO
(
gzdata
))
as
f
:
self
.
assertEqual
(
f
.
read
(),
b'Test'
)
class
TestOpen
(
BaseTest
):
class
TestOpen
(
BaseTest
):
def
test_binary_modes
(
self
):
def
test_binary_modes
(
self
):
...
...
Misc/NEWS
View file @
7e69f008
...
@@ -21,6 +21,8 @@ Core and Builtins
...
@@ -21,6 +21,8 @@ Core and Builtins
Library
Library
-------
-------
-
Issue
#
17666
:
Fix
reading
gzip
files
with
an
extra
field
.
-
Issue
#
17502
:
Process
DEFAULT
values
in
mock
side_effect
that
returns
iterator
.
-
Issue
#
17502
:
Process
DEFAULT
values
in
mock
side_effect
that
returns
iterator
.
Patch
by
Michael
Foord
.
Patch
by
Michael
Foord
.
...
...
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