diff options
| author | Serhiy Storchaka <storchaka@gmail.com> | 2014-01-18 14:14:10 (GMT) |
|---|---|---|
| committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-01-18 14:14:10 (GMT) |
| commit | c2d01423e02d9721f897812cf6a93e64c7d75c15 (patch) | |
| tree | 621f81bc2b6e40b3e87e4a1be364a1533dc39541 /Lib/test/test_tarfile.py | |
| parent | 9fbec7ad5e8fcdd9dcc5abd496341b86d12a4472 (diff) | |
| download | cpython-c2d01423e02d9721f897812cf6a93e64c7d75c15.zip cpython-c2d01423e02d9721f897812cf6a93e64c7d75c15.tar.gz cpython-c2d01423e02d9721f897812cf6a93e64c7d75c15.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 ceaa3aa..f22b908 100644 --- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -1155,6 +1155,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 |
