Skip to content

gh-119993 ignore NotADirectoryError in Path.unlink() if missing_ok is True#120049

Open
MusicalNinjaDad wants to merge 13 commits intopython:mainfrom
MusicalNinjaDad:MusicalNinjaDad/issue119993
Open

gh-119993 ignore NotADirectoryError in Path.unlink() if missing_ok is True#120049
MusicalNinjaDad wants to merge 13 commits intopython:mainfrom
MusicalNinjaDad:MusicalNinjaDad/issue119993

Conversation

@MusicalNinjaDad
Copy link

@MusicalNinjaDad MusicalNinjaDad commented Jun 4, 2024

Add a short note on when Path.unlink() raises NotADirectoryError

This can occur "in the wild", for example, after calling shutil.move(src, dst) where dst 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


📚 Documentation preview 📚: https://cpython-previews--120049.org.readthedocs.build/

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

pathlib.Path.unlink raises a NotADirectoryError if some element of the path is actually a file - this is undocumented

2 participants