- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 33.3k
          gh-119993 ignore NotADirectoryError in Path.unlink() if missing_ok is True
          #120049
        
          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
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  | 
| 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! | 
| @barneygale - I was unexpectedly offline for the last 6 months due to illness. 
 I see the ABC no longer includes  | 
…119993 Keep origin/main version of test_pathlib_abc.py - need to reimplement changes from MusicalNinjaDad/issue119993 in context of significant changes to class structure
| I have made the requested changes; please review again | 
| Thanks for making the requested changes! @barneygale: please review the changes made to this pull request. | 
| @barneygale - is there anything I can do to support with this? Should I rebase and reintegrate with all the work you've done on the ABCs? | 
Add a short note on when Path.unlink() raises
NotADirectoryErrorThis can occur "in the wild", for example, after calling
shutil.move(src, dst)wheredstis 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
NotADirectoryErrorif some element of the path is actually a file - this is undocumented #119993📚 Documentation preview 📚: https://cpython-previews--120049.org.readthedocs.build/