fixes: #1196
:thumbsup:
- except OSError: - #thrown when dir already exists (could happen in a race) - if not os.path.isdir(directory): + except OSError as e: + # do not thrown when dir already exists (could happen in a race) + if e.errno == errno.EEXIST and not os.path.isdir(directory):
I feel like we're masking a problem here. In what reasonable case can mkdir throw EEXIST and os.path.isdir return false at the same time?
I have no objection to the normpath.
The raises part in the docstring doesn't quite seem right. First case should be "argument already exists and is not a directory", and the second case isn't exactly our exception, it comes from mkdir. If we're going to document exceptions that the underlying mkdir might raise, then there are more possibilities that stated.
It's still possible that other program creates this file which is not a dir, after the first os.path.exists(directory) is called. hmm.. I masked all other errnos. will roll it back.
os.path.exists(directory)
rebased onto f893bf61e918670ab764013f8a01b2e0762600d7
Updated with the previous problem
Commit bff03c22 fixes this pull-request
Pull-Request has been merged by tkopecek
fixes: #1196