diff -r e1f0881d2cb4 Lib/tarfile.py --- a/Lib/tarfile.py Fri Apr 15 08:25:16 2011 +0300 +++ b/Lib/tarfile.py Fri Apr 15 09:24:41 2011 +0300 @@ -2196,9 +2196,11 @@ """ source = self.extractfile(tarinfo) target = bltn_open(targetpath, "wb") - copyfileobj(source, target) - source.close() - target.close() + try: + copyfileobj(source, target) + finally: + source.close() + target.close() def makeunknown(self, tarinfo, targetpath): """Make a file from a TarInfo object with an unknown type