Merge pull request #2289 from Xarthisius/race_fix

Use ensuredir() for creating directories within BuildEnvironment.read_doc
This commit is contained in:
Georg Brandl 2016-02-02 23:15:39 +01:00
commit eba0e314b3

View File

@ -40,7 +40,7 @@ from sphinx import addnodes
from sphinx.util import url_re, get_matching_docs, docname_join, split_into, \
FilenameUniqDict, get_figtype, import_object, split_index_msg
from sphinx.util.nodes import clean_astext, make_refnode, WarningStream, is_translatable
from sphinx.util.osutil import SEP, getcwd, fs_encoding
from sphinx.util.osutil import SEP, getcwd, fs_encoding, ensuredir
from sphinx.util.i18n import find_catalog_files
from sphinx.util.console import bold, purple
from sphinx.util.matching import compile_matchers
@ -855,9 +855,7 @@ class BuildEnvironment:
# save the parsed doctree
doctree_filename = self.doc2path(docname, self.doctreedir,
'.doctree')
dirname = path.dirname(doctree_filename)
if not path.isdir(dirname):
os.makedirs(dirname)
ensuredir(path.dirname(doctree_filename))
f = open(doctree_filename, 'wb')
try:
pickle.dump(doctree, f, pickle.HIGHEST_PROTOCOL)