From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 21 Nov 2022 11:05:32 +0000 (-0800) Subject: [3.10] GH-95815: Document less specific error for os.remove (GH-99571) (#99639) X-Git-Tag: v3.10.9~43 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=101dfaedb202c5dc1d940bffc953ab1f9aa10bc7;p=thirdparty%2FPython%2Fcpython.git [3.10] GH-95815: Document less specific error for os.remove (GH-99571) (#99639) GH-95815: Document less specific error for os.remove (GH-99571) os.remove can raise PermissionError instead of IsADirectoryError, when the object to be removed is a directory (in particular on macOS). This reverts a change done in GH-14262. (cherry picked from commit 1cae31d26ba621f6b1f0656ad3d69a0236338bad) Co-authored-by: Ronald Oussoren --- diff --git a/Doc/library/os.rst b/Doc/library/os.rst index 90ecc42294aa..7a5efcf5d79b 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -2256,7 +2256,7 @@ features: .. function:: remove(path, *, dir_fd=None) Remove (delete) the file *path*. If *path* is a directory, an - :exc:`IsADirectoryError` is raised. Use :func:`rmdir` to remove directories. + :exc:`OSError` is raised. Use :func:`rmdir` to remove directories. If the file does not exist, a :exc:`FileNotFoundError` is raised. This function can support :ref:`paths relative to directory descriptors