Kaydet (Commit) b130743e authored tarafından Georg Brandl's avatar Georg Brandl

Patch #1608267: fix a race condition in os.makedirs() is the directory

to be created is already there.
üst 66fab425
...@@ -25,6 +25,8 @@ and opendir), and leave all pathname manipulation to os.path ...@@ -25,6 +25,8 @@ and opendir), and leave all pathname manipulation to os.path
import sys import sys
from errno import ENOENT, ENOTDIR, EEXIST
_names = sys.builtin_module_names _names = sys.builtin_module_names
# Note: more names are added to __all__ later. # Note: more names are added to __all__ later.
...@@ -160,7 +162,12 @@ def makedirs(name, mode=0777): ...@@ -160,7 +162,12 @@ def makedirs(name, mode=0777):
if not tail: if not tail:
head, tail = path.split(head) 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) try:
makedirs(head, mode)
except OSError, e:
# be happy if someone already created the path
if e.errno != EEXIST:
raise
if tail == curdir: # xxx/newdir/. exists if xxx/newdir exists if tail == curdir: # xxx/newdir/. exists if xxx/newdir exists
return return
mkdir(name, mode) mkdir(name, mode)
...@@ -359,8 +366,6 @@ def execvpe(file, args, env): ...@@ -359,8 +366,6 @@ def execvpe(file, args, env):
__all__.extend(["execl","execle","execlp","execlpe","execvp","execvpe"]) __all__.extend(["execl","execle","execlp","execlpe","execvp","execvpe"])
def _execvpe(file, args, env=None): def _execvpe(file, args, env=None):
from errno import ENOENT, ENOTDIR
if env is not None: if env is not None:
func = execve func = execve
argrest = (args, env) argrest = (args, env)
......
...@@ -101,6 +101,9 @@ Core and builtins ...@@ -101,6 +101,9 @@ Core and builtins
Library Library
------- -------
- Patch #1608267: fix a race condition in os.makedirs() is the directory
to be created is already there.
- Patch #1610437: fix a tarfile bug with long filename headers. - Patch #1610437: fix a tarfile bug with long filename headers.
- Patch #1371075: Make ConfigParser accept optional dict type - Patch #1371075: Make ConfigParser accept optional dict type
......
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