mirror of
https://github.com/python/cpython.git
synced 2025-08-01 15:43:13 +00:00
Issue #20238: TarFile opened with external fileobj and "w:gz" mode didn't
write complete output on close.
This commit is contained in:
commit
7d68a1c921
3 changed files with 10 additions and 1 deletions
|
@ -1618,7 +1618,7 @@ class TarFile(object):
|
||||||
if not extfileobj and fileobj is not None:
|
if not extfileobj and fileobj is not None:
|
||||||
fileobj.close()
|
fileobj.close()
|
||||||
raise
|
raise
|
||||||
t._extfileobj = extfileobj
|
t._extfileobj = False
|
||||||
return t
|
return t
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
@ -857,6 +857,12 @@ class WriteTestBase(TarTest):
|
||||||
tar.addfile(tarfile.TarInfo("foo"))
|
tar.addfile(tarfile.TarInfo("foo"))
|
||||||
tar.close()
|
tar.close()
|
||||||
self.assertFalse(fobj.closed, "external fileobjs must never closed")
|
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):
|
class WriteTest(WriteTestBase, unittest.TestCase):
|
||||||
|
|
|
@ -25,6 +25,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #20238: TarFile opened with external fileobj and "w:gz" mode didn't
|
||||||
|
write complete output on close.
|
||||||
|
|
||||||
- Issue #20245: The open functions in the tarfile module now correctly handle
|
- Issue #20245: The open functions in the tarfile module now correctly handle
|
||||||
empty mode.
|
empty mode.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue