# Create nonexistent files in append mode.
self.mode = "w"
self._mode = "wb"
- fileobj = file(name, self._mode)
+ fileobj = bltn_open(name, self._mode)
self._extfileobj = False
else:
if name is None and hasattr(fileobj, "name"):
raise CompressionError("gzip module is not available")
if fileobj is None:
- fileobj = file(name, mode + "b")
+ fileobj = bltn_open(name, mode + "b")
try:
t = cls.taropen(name, mode,
# Append the tar header and data to the archive.
if tarinfo.isreg():
- f = file(name, "rb")
+ f = bltn_open(name, "rb")
self.addfile(tarinfo, f)
f.close()
"""Make a file called targetpath.
"""
source = self.extractfile(tarinfo)
- target = file(targetpath, "wb")
+ target = bltn_open(targetpath, "wb")
copyfileobj(source, target)
source.close()
target.close()
except TarError:
return False
+bltn_open = open
open = TarFile.open
for n, s in enumerate(self.seps):
self.arcdata[s] = s.join(self.line_gen) + s
self.arcfiles[s] = '%s-%d' % (TESTFN, n)
- file(self.arcfiles[s], "wb").write(self.arcdata[s])
+ open(self.arcfiles[s], "wb").write(self.arcdata[s])
def makeTestArchive(self, f, compression):
# Create the ZIP archive