summaryrefslogtreecommitdiff
path: root/Lib/tarfile.py
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2007-05-25 20:17:15 +0000
committerBrett Cannon <bcannon@gmail.com>2007-05-25 20:17:15 +0000
commit14044542f3a6415f89306dba8f4b9c11ee2b7737 (patch)
treeca54452444228bd0448684f4cc483d8edc7d2592 /Lib/tarfile.py
parented34095e35fe3ba197b3b5d568499934905e3c08 (diff)
downloadcpython-14044542f3a6415f89306dba8f4b9c11ee2b7737.tar.gz
Remove direct call's to file's constructor and replace them with calls to
open() as ths is considered best practice.
Diffstat (limited to 'Lib/tarfile.py')
-rw-r--r--Lib/tarfile.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index b6dc3ee4b3..4f4a1d9b6b 100644
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -1490,7 +1490,7 @@ class TarFile(object):
# 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"):
@@ -1667,7 +1667,7 @@ class TarFile(object):
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,
@@ -1928,7 +1928,7 @@ class TarFile(object):
# 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()
@@ -2139,7 +2139,7 @@ class TarFile(object):
"""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()
@@ -2484,4 +2484,5 @@ def is_tarfile(name):
except TarError:
return False
+bltn_open = open
open = TarFile.open