Fix ensuredir() in case of pre-existing file #5548
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Subject:
sphinx.util.osutil.ensuredir()
should give an error when an ordinary file (not directory) exists with the given name.Feature or Bugfix
Purpose
I'm currently in the process of debugging an issue with SageMath when upgrading from Sphinx 1.7 to Sphinx 1.8. I get a warning
[Errno 20] Not a directory
while copying static files due to #5541 which causes the static "directory" to be an ordinary file. This should be detected earlier byensuredir()
.The current pull request also changes the philosophy of the test: we don't care about the process (why did it fail?) but we care about the result (we want a directory with the given name). By not using
errno
, it is very likely also more portable, which is an additional advantage.