summaryrefslogtreecommitdiffstats
path: root/Lib/tarfile.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-01-18 14:14:00 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-01-18 14:14:00 (GMT)
commit7a278da4ee4ca2e4d98d8285c409dd1f370b46ce (patch)
tree0fe22b157863b8db4e9d25919b9697520982b77c /Lib/tarfile.py
parentcdf1ebd8feff4b1d9410f10a7c7c51a7cecad65a (diff)
downloadcpython-7a278da4ee4ca2e4d98d8285c409dd1f370b46ce.zip
cpython-7a278da4ee4ca2e4d98d8285c409dd1f370b46ce.tar.gz
cpython-7a278da4ee4ca2e4d98d8285c409dd1f370b46ce.tar.bz2
Issue #20243: TarFile no longer raise ReadError when opened in write mode.
Diffstat (limited to 'Lib/tarfile.py')
-rw-r--r--Lib/tarfile.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index dd8a142..57ea877 100644
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -1726,7 +1726,9 @@ class TarFile(object):
gzip.GzipFile(name, mode, compresslevel, fileobj),
**kwargs)
except IOError:
- raise ReadError("not a gzip file")
+ if mode == 'r':
+ raise ReadError("not a gzip file")
+ raise
t._extfileobj = False
return t
@@ -1751,7 +1753,9 @@ class TarFile(object):
try:
t = cls.taropen(name, mode, fileobj, **kwargs)
except (IOError, EOFError):
- raise ReadError("not a bzip2 file")
+ if mode == 'r':
+ raise ReadError("not a bzip2 file")
+ raise
t._extfileobj = False
return t