Issue #20238: TarFile opened with external fileobj and "w:gz" mode didn't
write complete output on close.
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index 987c011..8a69988 100755
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -1642,7 +1642,7 @@
             if not extfileobj and fileobj is not None:
                 fileobj.close()
             raise
-        t._extfileobj = extfileobj
+        t._extfileobj = False
         return t
 
     @classmethod