Merge pull request #3258 from swgillespie/swgillespie/toctou-mkdir

Fix a TOCTOU issue in mkdir_p
This commit is contained in:
Dan Ryan
2018-11-19 20:19:08 -05:00
committed by GitHub
2 changed files with 12 additions and 1 deletions
+1
View File
@@ -0,0 +1 @@
Fixed an issue where pipenv could crash when multiple pipenv processes attempted to create the same directory.
+11 -1
View File
@@ -832,8 +832,18 @@ def mkdir_p(newdir):
if head and not os.path.isdir(head):
mkdir_p(head)
if tail:
os.mkdir(newdir)
# Even though we've checked that the directory doesn't exist above, it might exist
# now if some other process has created it between now and the time we checked it.
try:
os.mkdir(newdir)
except OSError as exn:
# If we failed because the directory does exist, that's not a problem -
# that's what we were trying to do anyway. Only re-raise the exception
# if we failed for some other reason.
if exn.errno != errno.EEXIST:
raise
def is_required_version(version, specified_version):
"""Check to see if there's a hard requirement for version