This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ssam
Recipients ssam
Date 2012-11-15.12:49:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1352983787.27.0.404679122442.issue16477@psf.upfronthosting.co.za>
In-reply-to
Content
Exceptions such as disk full during extraction cause tarfile to leak file handles. Besides being messy, it causes real problems if, for example, the target file is on a mount that should be unmounted before the program exits - in this case, the unmount will fail as there are still open file handles.

Simplest solution I can see is to change:

    def makefile(self, tarinfo, targetpath):
        """Make a file called targetpath.
        """
        source = self.extractfile(tarinfo)
        target = bltn_open(targetpath, "wb")
        copyfileobj(source, target)
        source.close()
        target.close()

to this:

    def makefile(self, tarinfo, targetpath):
        """Make a file called targetpath.
        """
        source = self.extractfile(tarinfo)
        try:
            with open(targetpath, "wb") as target:
                shutil.copyfileobj(source, target)
        finally:
            source.close()
History
Date User Action Args
2012-11-15 12:49:47ssamsetrecipients: + ssam
2012-11-15 12:49:47ssamsetmessageid: <1352983787.27.0.404679122442.issue16477@psf.upfronthosting.co.za>
2012-11-15 12:49:47ssamlinkissue16477 messages
2012-11-15 12:49:46ssamcreate