]> granicus.if.org Git - python/commitdiff
makedirs(), removedirs(): If the tail of the path is empty, do a second
authorFred Drake <fdrake@acm.org>
Tue, 25 Jul 2000 15:16:40 +0000 (15:16 +0000)
committerFred Drake <fdrake@acm.org>
Tue, 25 Jul 2000 15:16:40 +0000 (15:16 +0000)
split so the logic does not fail in corner cases.

This closes bug #407.

Lib/os.py

index 8e1e4f053a22d08efe3fddcaef030694168aab21..59c3895920dad45c85d9632ef14fa5bd2faa69fe 100644 (file)
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -126,6 +126,8 @@ def makedirs(name, mode=0777):
 
     """
     head, tail = path.split(name)
+    if not tail:
+        head, tail = path.split(head)
     if head and tail and not path.exists(head):
         makedirs(head, mode)
     mkdir(name, mode)
@@ -143,6 +145,8 @@ def removedirs(name):
     """
     rmdir(name)
     head, tail = path.split(name)
+    if not tail:
+        head, tail = path.split(head)
     while head and tail:
         try:
             rmdir(head)