-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-119993 ignore NotADirectoryError
in Path.unlink()
if missing_ok
is True
#120049
base: main
Are you sure you want to change the base?
gh-119993 ignore NotADirectoryError
in Path.unlink()
if missing_ok
is True
#120049
Conversation
Semantically equivalent to FileNotFoundError - the file to be unlinked does not exist
613cdb2
to
ce3577d
Compare
NotADirectoryError
is raised by Path.unlink()NotADirectoryError
in Path.unlink()
if missing_ok
is `True
NotADirectoryError
in Path.unlink()
if missing_ok
is `TrueNotADirectoryError
in Path.unlink()
if missing_ok
is True
@barneygale - this is how Windows works differently from Linux/MacOS and raises |
if sys.platform.startswith("win"): | ||
self.assertFileNotFound(p.unlink) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a @needs_posix
decorator to the test and don't bother testing Windows IMO :]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this hurt to have it in? Isn't it generally better to have the extra test coverage, or are we really struggling to keep execution times down?
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase And if you don't make the requested changes, you will be put in the comfy chair! |
Add a short note on when Path.unlink() raises
NotADirectoryError
This can occur "in the wild", for example, after calling
shutil.move(src, dst)
wheredst
is a non-existent directory. Debugging can cost a lot of time as the cause can be non-intuitive, potentially not nearby in the code and the docs don't mention the exception as being raised in any circumstances.(This just happened to me after encountering pypa/cibuildwheel#1850)
Fixes: #119993
NotADirectoryError
if some element of the path is actually a file - this is undocumented #119993📚 Documentation preview 📚: https://cpython-previews--120049.org.readthedocs.build/