source.close()
# only if we are extracting a multivolume this can be treated
if not self.new_volume_handler:
- target.close()
raise Exception("We need to read a new volume and you"
" didn't supply a new_volume_handler")
tarinfo = self.firstmember
source = self.fileobj
iterate = True
- target.close()
+ finally:
+ if iterate is False: target.close()
def makeunknown(self, tarinfo, targetpath):
return acc
infos += functools.reduce (aux, offsets, [])
+ fileobj.close()
+
nvol += 1
def aux (o, nvol, ti):
tarobj.close()
os.unlink("big")
- fo = open("sample.tar.gz", 'rb')
+ fo = open("sample.tar.gz", 'rb') # will not be released on tarfile.close()
fo.seek(pos)
tarobj = TarFile.open(mode="r#gz", fileobj=fo)
tarobj.extract(tarobj.next())
tarobj.close()
+ fo.close()
assert os.path.exists("big")
assert hash == self.md5sum("big")
os.unlink("small2")
# extract only the "small" file
- fo = open("sample.tar.gz", 'rb')
+ fo = open("sample.tar.gz", 'rb') # will not be released on tarfile.close()
fo.seek(pos)
tarobj = TarFile.open(mode="r#gz", fileobj=fo)
tarobj.extract(tarobj.next())
tarobj.close()
+ fo.close()
assert os.path.exists("small")
assert hash['small'] == self.md5sum("small")
tarobj.open_volume(volume_path)
# extract only the "small" file
- fo = open("sample.tar.gz", 'rb')
+ fo = open("sample.tar.gz", 'rb') # will not be released on tarfile.close()
fo.seek(pos)
tarobj = TarFile.open(mode="r#gz", fileobj=fo,
new_volume_handler=new_volume_handler_fo)
tarobj.extract(tarobj.next())
tarobj.close()
+ fo.close()
assert os.path.exists("big")
assert hash['big'] == self.md5sum("big")