mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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.
This commit is contained in:
parent
0365180a74
commit
9f2550f581
1 changed files with 4 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue