From: Serhiy Storchaka Date: Sat, 18 Jan 2014 14:14:49 +0000 (+0200) Subject: Issue #20243: TarFile no longer raise ReadError when opened in write mode. X-Git-Tag: v3.4.0b3~105 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aee0e63ed052ae891e4b5f342aae512787098fa4;p=python Issue #20243: TarFile no longer raise ReadError when opened in write mode. --- aee0e63ed052ae891e4b5f342aae512787098fa4 diff --cc Lib/tarfile.py index ec8af06498,6c40cb9596..d914485c66 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@@ -1639,9 -1666,11 +1642,11 @@@ class TarFile(object) try: t = cls.taropen(name, mode, fileobj, **kwargs) - except (IOError, EOFError): + except (OSError, EOFError): fileobj.close() - raise ReadError("not a bzip2 file") + if mode == 'r': + raise ReadError("not a bzip2 file") + raise t._extfileobj = False return t