Commit 849d5b99 authored by Fred Drake's avatar Fred Drake

makedirs(), removedirs(): If the tail of the path is empty, do a second

	split so the logic does not fail in corner cases.

This closes bug #407.
parent c343a39d
...@@ -126,6 +126,8 @@ def makedirs(name, mode=0777): ...@@ -126,6 +126,8 @@ def makedirs(name, mode=0777):
""" """
head, tail = path.split(name) head, tail = path.split(name)
if not tail:
head, tail = path.split(head)
if head and tail and not path.exists(head): if head and tail and not path.exists(head):
makedirs(head, mode) makedirs(head, mode)
mkdir(name, mode) mkdir(name, mode)
...@@ -143,6 +145,8 @@ def removedirs(name): ...@@ -143,6 +145,8 @@ def removedirs(name):
""" """
rmdir(name) rmdir(name)
head, tail = path.split(name) head, tail = path.split(name)
if not tail:
head, tail = path.split(head)
while head and tail: while head and tail:
try: try:
rmdir(head) rmdir(head)
......
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