Skip to content

Commit 28e1c91

Browse files
committed
pythongh-145227: Clarify os.remove() directory exception is platform-dependent
1 parent 7eb00ad commit 28e1c91

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

Doc/library/os.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2732,7 +2732,9 @@ features:
27322732
.. function:: remove(path, *, dir_fd=None)
27332733

27342734
Remove (delete) the file *path*. If *path* is a directory, an
2735-
:exc:`OSError` is raised. Use :func:`rmdir` to remove directories.
2735+
:exc:`OSError` is raised. The exact exception type depends on the platform:
2736+
for example, :exc:`IsADirectoryError` or :exc:`PermissionError`.
2737+
Use :func:`rmdir` to remove directories.
27362738
If the file does not exist, a :exc:`FileNotFoundError` is raised.
27372739

27382740
This function can support :ref:`paths relative to directory descriptors
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Clarify that the :exc:`OSError` subclass raised by :func:`os.remove` when the
2+
path is a directory is platform-dependent.

0 commit comments

Comments
 (0)