[Python-3000-checkins] r51539 - python/branches/p3yk/Lib/tarfile.py

guido.van.rossum python-3000-checkins at python.org
Thu Aug 24 06:03:54 CEST 2006


Author: guido.van.rossum
Date: Thu Aug 24 06:03:53 2006
New Revision: 51539

Modified:
   python/branches/p3yk/Lib/tarfile.py
Log:
Fix fallout from Anna's file -> open changes.


Modified: python/branches/p3yk/Lib/tarfile.py
==============================================================================
--- python/branches/p3yk/Lib/tarfile.py	(original)
+++ python/branches/p3yk/Lib/tarfile.py	Thu Aug 24 06:03:53 2006
@@ -65,6 +65,8 @@
 # from tarfile import *
 __all__ = ["TarFile", "TarInfo", "is_tarfile", "TarError"]
 
+from __builtin__ import open as _open # Since 'open' is TarFile.open
+
 #---------------------------------------------------------
 # tar constants
 #---------------------------------------------------------
@@ -934,7 +936,7 @@
         self.mode = {"r": "rb", "a": "r+b", "w": "wb"}[mode]
 
         if not fileobj:
-            fileobj = open(self.name, self.mode)
+            fileobj = _open(self.name, self.mode)
             self._extfileobj = False
         else:
             if self.name is None and hasattr(fileobj, "name"):
@@ -1083,7 +1085,7 @@
         tarname = pre + ext
 
         if fileobj is None:
-            fileobj = open(name, mode + "b")
+            fileobj = _open(name, mode + "b")
 
         if mode != "r":
             name = tarname
@@ -1355,7 +1357,7 @@
 
         # Append the tar header and data to the archive.
         if tarinfo.isreg():
-            f = open(name, "rb")
+            f = _open(name, "rb")
             self.addfile(tarinfo, f)
             f.close()
 
@@ -1617,7 +1619,7 @@
         """Make a file called targetpath.
         """
         source = self.extractfile(tarinfo)
-        target = open(targetpath, "wb")
+        target = _open(targetpath, "wb")
         copyfileobj(source, target)
         source.close()
         target.close()


More information about the Python-3000-checkins mailing list