Commit 925dd35e authored by Jason R. Coombs's avatar Jason R. Coombs

Avoid race condition in ensure_directory. Ref #1083.

parent 995d3093
v36.1.0
-------
* #1083: Avoid race condition on directory creation in
``pkg_resources.ensure_directory``.
* Removed deprecation of and restored support for
``upload_docs`` command for sites other than PyPI.
Only warehouse is dropping support, but services like
......
......@@ -67,6 +67,7 @@ try:
except ImportError:
importlib_machinery = None
from . import py31compat
from pkg_resources.extern import appdirs
from pkg_resources.extern import packaging
__import__('pkg_resources.extern.packaging.version')
......@@ -74,6 +75,7 @@ __import__('pkg_resources.extern.packaging.specifiers')
__import__('pkg_resources.extern.packaging.requirements')
__import__('pkg_resources.extern.packaging.markers')
if (3, 0) < sys.version_info < (3, 3):
raise RuntimeError("Python 3.3 or later is required")
......@@ -2958,8 +2960,7 @@ def _find_adapter(registry, ob):
def ensure_directory(path):
"""Ensure that the parent directory of `path` exists"""
dirname = os.path.dirname(path)
if not os.path.isdir(dirname):
os.makedirs(dirname)
py31compat.makedirs(dirname, exist_ok=True)
def _bypass_ensure_directory(path):
......
import os
import errno
import sys
PY32 = sys.version_info >= (3, 2)
def _makedirs_31(path, exist_ok=False):
try:
os.makedirs(path)
except OSError as exc:
if exc.errno != errno.EEXIST:
raise
makedirs = os.makedirs if PY32 else _makedirs_31
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