From 00d30722bc623f077b946b2ca15e90c17aad81b2 Mon Sep 17 00:00:00 2001 From: Olayinka Vaughan Date: Sat, 14 Nov 2026 18:39:34 +0000 Subject: [PATCH 1/2] docs(shutil): document path-like commands --- Doc/library/shutil.rst | 7 +++++++ .../Library/2026-11-10-23-51-25.gh-issue-161788.J8vQmK.rst | 3 +-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst index 6104ad3d3a801b1..9a5dd6e09866dc2 100644 --- a/Doc/library/shutil.rst +++ b/Doc/library/shutil.rst @@ -482,6 +482,10 @@ Directory and files operations Return the path to an executable which would be run if the given *cmd* was called. If no *cmd* would be called, return ``None``. + *cmd* may be a string, bytes, or a :term:`path-like object`. + If *cmd* is a path-like object and an executable is found, the result has + the same type as the value returned by its :meth:`~os.PathLike.__fspath__` + method. *mode* is a permission mask passed to :func:`os.access`, by default determining if the file exists and is executable. @@ -532,6 +536,9 @@ Directory and files operations or ends with an extension that is in ``PATHEXT``; and filenames that have no extension can now be found. + .. versionchanged:: next + Accepts a :term:`path-like object` for *cmd*. + .. exception:: Error Subclass of :exc:`OSError` collecting exceptions raised during a multi-file diff --git a/Misc/NEWS.d/next/Library/2026-11-10-23-51-25.gh-issue-161788.J8vQmK.rst b/Misc/NEWS.d/next/Library/2026-11-10-23-51-25.gh-issue-161788.J8vQmK.rst index 21565e386cd3cc6..34d3cff85123c79 100644 --- a/Misc/NEWS.d/next/Library/2026-11-10-23-51-25.gh-issue-161788.J8vQmK.rst +++ b/Misc/NEWS.d/next/Library/2026-11-10-23-51-25.gh-issue-161788.J8vQmK.rst @@ -1,2 +1 @@ -Fix :func:`shutil.which` for path-like command objects whose -:meth:`~os.PathLike.__fspath__` method returns :class:`bytes`. +:func:`shutil.which` now accepts path-like objects for the command. From 9ca3b9de1f0e527bbb50022822ffa993d71aa41f Mon Sep 17 00:00:00 2001 From: Olayinka Vaughan Date: Sat, 14 Nov 2026 23:43:48 +0000 Subject: [PATCH 2/2] docs: trim which documentation --- Doc/library/shutil.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst index 9a5dd6e09866dc2..db484beaf4b2abe 100644 --- a/Doc/library/shutil.rst +++ b/Doc/library/shutil.rst @@ -482,10 +482,6 @@ Directory and files operations Return the path to an executable which would be run if the given *cmd* was called. If no *cmd* would be called, return ``None``. - *cmd* may be a string, bytes, or a :term:`path-like object`. - If *cmd* is a path-like object and an executable is found, the result has - the same type as the value returned by its :meth:`~os.PathLike.__fspath__` - method. *mode* is a permission mask passed to :func:`os.access`, by default determining if the file exists and is executable.