]> granicus.if.org Git - python/commitdiff
Fix directory names to have only one trailing slash.
authorLars Gustäbel <lars@gustaebel.de>
Fri, 20 Apr 2007 14:49:02 +0000 (14:49 +0000)
committerLars Gustäbel <lars@gustaebel.de>
Fri, 20 Apr 2007 14:49:02 +0000 (14:49 +0000)
A regression from rev. 52525.

Lib/tarfile.py
Lib/test/test_tarfile.py
Misc/NEWS

index 4c7dadbc6ad744e17d21360a7a8cbe318ced343a..261d9fbc3620dd96168fce4d386b0f47010741f4 100644 (file)
@@ -1842,7 +1842,7 @@ class TarFile(object):
             tarinfo.type = DIRTYPE
 
         # Directory names should have a '/' at the end.
-        if tarinfo.isdir():
+        if tarinfo.isdir() and not tarinfo.name.endswith("/"):
             tarinfo.name += "/"
 
         self.members.append(tarinfo)
index 692d72a17ccad3b5fe4b4b501d5937239888c3ec..b1cbcf69c3062c33db8cb93c0d1eb8c1c7437358 100644 (file)
@@ -191,6 +191,13 @@ class ReadTest(BaseTest):
             except:
                 pass
 
+    def test_dirtype(self):
+        for tarinfo in self.tar:
+            if tarinfo.isdir():
+                self.assert_(tarinfo.name.endswith("/"))
+                self.assert_(not tarinfo.name[:-1].endswith("/"))
+
+
 class ReadStreamTest(ReadTest):
     sep = "|"
 
index 6475b767d543c6c7a4e688e684f985e8bd75c85d..58f87eac662104064a4731111b8239bdec78b289 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -4,6 +4,17 @@ Python News
 
 (editors: check NEWS.help for information about editing NEWS using ReST.)
 
+What's New in Python 2.5.2c1?
+=============================
+
+*Release date: XX-XXX-XXXX*
+
+Library
+-------
+
+- tarfile.py: Fix directory names to have only one trailing slash.
+
+
 What's New in Python 2.5.1?
 =============================