diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-01-18 14:14:49 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-01-18 14:14:49 (GMT) |
commit | aee0e63ed052ae891e4b5f342aae512787098fa4 (patch) | |
tree | 5c9b8a65a85398af239317bb84264f6141c7d439 /Lib/test/test_tarfile.py | |
parent | 7d68a1c921bb53c5b72fc7a884fc048185001f2c (diff) | |
parent | c2d01423e02d9721f897812cf6a93e64c7d75c15 (diff) | |
download | cpython-aee0e63ed052ae891e4b5f342aae512787098fa4.zip cpython-aee0e63ed052ae891e4b5f342aae512787098fa4.tar.gz cpython-aee0e63ed052ae891e4b5f342aae512787098fa4.tar.bz2 |
Issue #20243: TarFile no longer raise ReadError when opened in write mode.
Diffstat (limited to 'Lib/test/test_tarfile.py')
-rw-r--r-- | Lib/test/test_tarfile.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py index e0c9103..b53f3ac 100644 --- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -1157,6 +1157,22 @@ class WriteTest(WriteTestBase, unittest.TestCase): finally: os.chdir(cwd) + def test_open_nonwritable_fileobj(self): + for exctype in OSError, EOFError, RuntimeError: + class BadFile(io.BytesIO): + first = True + def write(self, data): + if self.first: + self.first = False + raise exctype + + f = BadFile() + with self.assertRaises(exctype): + tar = tarfile.open(tmpname, self.mode, fileobj=f, + format=tarfile.PAX_FORMAT, + pax_headers={'non': 'empty'}) + self.assertFalse(f.closed) + class GzipWriteTest(GzipTest, WriteTest): pass |