Documentation
Currently, the os.remove() documentation specifies that OSError is returned when trying to remove a directory:
Remove (delete) the file *path*. If *path* is a directory, an
:exc:`OSError` is raised. Use :func:`rmdir` to remove directories.
If the file does not exist, a :exc:`FileNotFoundError` is raised.
However, actually a PermissionError: [Errno 1] Operation not permitted (subclass of OsError) is returned instead.
While this is technically correct, it causes excepting PermissionError to silently fail unexpectedly in code that expects a generic OSError when meeting a directory.
I would suggest the documentation should read
If *path* is a directory, a :exc:`PermissionError` is raised.
Linked PRs
Documentation
Currently, the os.remove() documentation specifies that
OSErroris returned when trying to remove a directory:However, actually a
PermissionError: [Errno 1] Operation not permitted(subclass ofOsError) is returned instead.While this is technically correct, it causes excepting
PermissionErrorto silently fail unexpectedly in code that expects a generic OSError when meeting a directory.I would suggest the documentation should read
Linked PRs