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
dde3f2b8
Commit
dde3f2b8
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
799f5a0a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
4 deletions
+23
-4
Lib/gzip.py
Lib/gzip.py
+2
-1
Lib/test/test_gzip.py
Lib/test/test_gzip.py
+7
-0
Misc/NEWS
Misc/NEWS
+14
-3
No files found.
Lib/gzip.py
View file @
dde3f2b8
...
...
@@ -280,7 +280,8 @@ class GzipFile(io.BufferedIOBase):
if
flag
&
FEXTRA
:
# 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
:
# Read and discard a null-terminated string containing the filename
while
True
:
...
...
Lib/test/test_gzip.py
View file @
dde3f2b8
...
...
@@ -379,6 +379,13 @@ class TestGzip(unittest.TestCase):
with
gzip
.
GzipFile
(
fileobj
=
io
.
BytesIO
(
truncated
[:
i
]))
as
f
:
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'
)
def
test_main
(
verbose
=
None
):
support
.
run_unittest
(
TestGzip
)
...
...
Misc/NEWS
View file @
dde3f2b8
...
...
@@ -2,18 +2,29 @@
Python News
+++++++++++
What's New in Python 3.2.
4
?
What's New in Python 3.2.
5
?
===========================
*Release date:
07-Apr
-2013*
*Release date:
13-May
-2013*
Library
-------
- Issue #17192: Restore the patch for Issue #11729 and Issue #10309
which were om
m
itted in 3.2.4 when updating the bundled version of
which were omitted in 3.2.4 when updating the bundled version of
libffi used by ctypes.
- Issue #17666: Fix reading gzip files with an extra field.
What's New in Python 3.2.4?
===========================
*Release date: 07-Apr-2013*
Library
-------
- Issue #17625: In IDLE, close the replace dialog after it is used.
...
...
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