utils: Teach mkdir_p to fail if the existing target isn't a directory

Existing symlinks to directories will still pass, because isdir()
follows symbolic links.
This commit is contained in:
W. Trevor King 2013-01-04 07:29:23 -05:00
commit c3c3037a1d

View file

@ -416,5 +416,5 @@ def mkdir_p(path):
try:
os.makedirs(path)
except OSError as e:
if e.errno != errno.EEXIST:
if e.errno != errno.EEXIST or not os.path.isdir(path):
raise