Kaydet (Commit) 8f78fe9a authored tarafından Guido van Rossum's avatar Guido van Rossum

Fix fallout from Anna's file -> open changes.

üst b053cd8f
...@@ -65,6 +65,8 @@ except ImportError: ...@@ -65,6 +65,8 @@ except ImportError:
# from tarfile import * # from tarfile import *
__all__ = ["TarFile", "TarInfo", "is_tarfile", "TarError"] __all__ = ["TarFile", "TarInfo", "is_tarfile", "TarError"]
from __builtin__ import open as _open # Since 'open' is TarFile.open
#--------------------------------------------------------- #---------------------------------------------------------
# tar constants # tar constants
#--------------------------------------------------------- #---------------------------------------------------------
...@@ -934,7 +936,7 @@ class TarFile(object): ...@@ -934,7 +936,7 @@ class TarFile(object):
self.mode = {"r": "rb", "a": "r+b", "w": "wb"}[mode] self.mode = {"r": "rb", "a": "r+b", "w": "wb"}[mode]
if not fileobj: if not fileobj:
fileobj = open(self.name, self.mode) fileobj = _open(self.name, self.mode)
self._extfileobj = False self._extfileobj = False
else: else:
if self.name is None and hasattr(fileobj, "name"): if self.name is None and hasattr(fileobj, "name"):
...@@ -1083,7 +1085,7 @@ class TarFile(object): ...@@ -1083,7 +1085,7 @@ class TarFile(object):
tarname = pre + ext tarname = pre + ext
if fileobj is None: if fileobj is None:
fileobj = open(name, mode + "b") fileobj = _open(name, mode + "b")
if mode != "r": if mode != "r":
name = tarname name = tarname
...@@ -1355,7 +1357,7 @@ class TarFile(object): ...@@ -1355,7 +1357,7 @@ class TarFile(object):
# Append the tar header and data to the archive. # Append the tar header and data to the archive.
if tarinfo.isreg(): if tarinfo.isreg():
f = open(name, "rb") f = _open(name, "rb")
self.addfile(tarinfo, f) self.addfile(tarinfo, f)
f.close() f.close()
...@@ -1617,7 +1619,7 @@ class TarFile(object): ...@@ -1617,7 +1619,7 @@ class TarFile(object):
"""Make a file called targetpath. """Make a file called targetpath.
""" """
source = self.extractfile(tarinfo) source = self.extractfile(tarinfo)
target = open(targetpath, "wb") target = _open(targetpath, "wb")
copyfileobj(source, target) copyfileobj(source, target)
source.close() source.close()
target.close() target.close()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment