Issue #20238: TarFile opened with external fileobj and "w:gz" mode didn't
write complete output on close.
This commit is contained in:
parent
53ad0cd284
commit
9fbec7ad5e
|
@ -1642,7 +1642,7 @@ class TarFile(object):
|
|||
if not extfileobj and fileobj is not None:
|
||||
fileobj.close()
|
||||
raise
|
||||
t._extfileobj = extfileobj
|
||||
t._extfileobj = False
|
||||
return t
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -855,6 +855,12 @@ class WriteTestBase(TarTest):
|
|||
tar.addfile(tarfile.TarInfo("foo"))
|
||||
tar.close()
|
||||
self.assertFalse(fobj.closed, "external fileobjs must never closed")
|
||||
# Issue #20238: Incomplete gzip output with mode="w:gz"
|
||||
data = fobj.getvalue()
|
||||
del tar
|
||||
support.gc_collect()
|
||||
self.assertFalse(fobj.closed)
|
||||
self.assertEqual(data, fobj.getvalue())
|
||||
|
||||
|
||||
class WriteTest(WriteTestBase, unittest.TestCase):
|
||||
|
|
Loading…
Reference in New Issue