[Python-checkins] r54889 - in python/branches/release25-maint: Lib/tarfile.py Lib/test/test_tarfile.py Misc/NEWS

lars.gustaebel python-checkins at python.org
Fri Apr 20 22:11:00 CEST 2007


Author: lars.gustaebel
Date: Fri Apr 20 22:10:59 2007
New Revision: 54889

Modified:
   python/branches/release25-maint/Lib/tarfile.py
   python/branches/release25-maint/Lib/test/test_tarfile.py
   python/branches/release25-maint/Misc/NEWS
Log:
Patch #1695229: Fix a regression with tarfile.open() and a missing name
argument.


Modified: python/branches/release25-maint/Lib/tarfile.py
==============================================================================
--- python/branches/release25-maint/Lib/tarfile.py	(original)
+++ python/branches/release25-maint/Lib/tarfile.py	Fri Apr 20 22:10:59 2007
@@ -1044,7 +1044,9 @@
            can be determined, `mode' is overridden by `fileobj's mode.
            `fileobj' is not closed, when TarFile is closed.
         """
-        self.name = os.path.abspath(name)
+        self.name = name
+        if self.name is not None:
+            self.name = os.path.abspath(name)
 
         if len(mode) > 1 or mode not in "raw":
             raise ValueError("mode must be 'r', 'a' or 'w'")

Modified: python/branches/release25-maint/Lib/test/test_tarfile.py
==============================================================================
--- python/branches/release25-maint/Lib/test/test_tarfile.py	(original)
+++ python/branches/release25-maint/Lib/test/test_tarfile.py	Fri Apr 20 22:10:59 2007
@@ -633,15 +633,21 @@
         self.assertEqual(tarfile.filemode(07111), '---s--s--t')
 
 class OpenFileobjTest(BaseTest):
-    # Test for SF bug #1496501.
 
     def test_opener(self):
+        # Test for SF bug #1496501.
         fobj = StringIO.StringIO("foo\n")
         try:
-            tarfile.open("", "r", fileobj=fobj)
+            tarfile.open("", mode="r", fileobj=fobj)
         except tarfile.ReadError:
             self.assertEqual(fobj.tell(), 0, "fileobj's position has moved")
 
+    def test_fileobj(self):
+        # Test for SF bug #1695229, opening a tarfile without
+        # a name argument.
+        tarfile.open(mode="r", fileobj=open(tarname("")))
+        tarfile.TarFile(mode="r", fileobj=open(tarname("")))
+
 if bz2:
     # Bzip2 TestCases
     class ReadTestBzip2(ReadTestGzip):

Modified: python/branches/release25-maint/Misc/NEWS
==============================================================================
--- python/branches/release25-maint/Misc/NEWS	(original)
+++ python/branches/release25-maint/Misc/NEWS	Fri Apr 20 22:10:59 2007
@@ -12,6 +12,9 @@
 Library
 -------
 
+- Patch #1695229: Fix a regression with tarfile.open() and a missing name
+  argument.
+
 - tarfile.py: Fix directory names to have only one trailing slash.
 
 


More information about the Python-checkins mailing list