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
3abb372c
Commit
3abb372c
authored
Aug 13, 2011
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #11513: wrong exception handling for the case that GzipFile itself raises an IOError.
parent
963e4025
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
2 deletions
+15
-2
Lib/tarfile.py
Lib/tarfile.py
+4
-2
Lib/test/test_tarfile.py
Lib/test/test_tarfile.py
+8
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/tarfile.py
View file @
3abb372c
...
...
@@ -1804,11 +1804,13 @@ class TarFile(object):
fileobj = gzip.GzipFile(name, mode + "b", compresslevel, fileobj)
t = cls.taropen(name, mode, fileobj, **kwargs)
except IOError:
if not extfileobj:
if not extfileobj
and fileobj is not None
:
fileobj.close()
if fileobj is None:
raise
raise ReadError("
not
a
gzip
file
")
except:
if not extfileobj:
if not extfileobj
and fileobj is not None
:
fileobj.close()
raise
t._extfileobj = extfileobj
...
...
Lib/test/test_tarfile.py
View file @
3abb372c
...
...
@@ -1682,6 +1682,14 @@ class LinkEmulationTest(ReadTest):
class
GzipMiscReadTest
(
MiscReadTest
):
tarname
=
gzipname
mode
=
"r:gz"
def
test_non_existent_targz_file
(
self
):
# Test for issue11513: prevent non-existent gzipped tarfiles raising
# multiple exceptions.
with
self
.
assertRaisesRegex
(
IOError
,
"xxx"
)
as
ex
:
tarfile
.
open
(
"xxx"
,
self
.
mode
)
self
.
assertEqual
(
ex
.
exception
.
errno
,
errno
.
ENOENT
)
class
GzipUstarReadTest
(
UstarReadTest
):
tarname
=
gzipname
mode
=
"r:gz"
...
...
Misc/NEWS
View file @
3abb372c
...
...
@@ -44,6 +44,9 @@ Core and Builtins
Library
-------
- Issue #11513: Fix exception handling ``tarfile.TarFile.gzopen()`` when
the file cannot be opened.
- Issue #12687: Fix a possible buffering bug when unpickling text mode
(protocol 0, mostly) pickles.
...
...
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