From ac37c184920fdf6f2b0a184bb104e89f2a82266d Mon Sep 17 00:00:00 2001 From: Anvesh <19anveshh@gmail.com> Date: Fri, 6 Nov 2026 00:55:56 +0530 Subject: [PATCH 1/2] gh-160904: Correct os.path.normcase documentation for POSIX The docstring and docs incorrectly stated that normcase 'has no effect' or 'returns the path unchanged' on Posix. In reality, it calls os.fspath(s), which converts path-like objects to str or bytes. --- Doc/library/os.path.rst | 3 ++- Lib/posixpath.py | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst index f5ddb426c915f5a..1b5a3ec724d687d 100644 --- a/Doc/library/os.path.rst +++ b/Doc/library/os.path.rst @@ -415,7 +415,8 @@ the :mod:`glob` module.) Normalize the case of a pathname. On Windows, convert all characters in the pathname to lowercase, and also convert forward slashes to backward slashes. - On other operating systems, return the path unchanged. + On other operating systems, this calls :func:`os.fspath` to convert + path-like objects to ``str`` or ``bytes``. .. versionchanged:: 3.6 Accepts a :term:`path-like object`. diff --git a/Lib/posixpath.py b/Lib/posixpath.py index 8025b063397a038..fafde27f4d95b19 100644 --- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -52,7 +52,11 @@ def _get_sep(path): # (another function should be defined to do that). def normcase(s, /): - """Normalize case of pathname. Has no effect under Posix""" + """Normalize case of pathname. Has no effect under Posix. + + On Posix, this calls os.fspath(s), which converts path-like objects + to str or bytes. + """ return os.fspath(s) From 21f78a7b828622571ef1b2b87097c4e2471a7cf0 Mon Sep 17 00:00:00 2001 From: Anvesh <19anveshh@gmail.com> Date: Fri, 6 Nov 2026 01:08:01 +0530 Subject: [PATCH 2/2] Add news entry for gh-160904 normcase doc fix --- .../2026-11-06-01-07-31.gh-issue-160904.normcase-doc.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Documentation/2026-11-06-01-07-31.gh-issue-160904.normcase-doc.rst diff --git a/Misc/NEWS.d/next/Documentation/2026-11-06-01-07-31.gh-issue-160904.normcase-doc.rst b/Misc/NEWS.d/next/Documentation/2026-11-06-01-07-31.gh-issue-160904.normcase-doc.rst new file mode 100644 index 000000000000000..52c486cbf266450 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2026-11-06-01-07-31.gh-issue-160904.normcase-doc.rst @@ -0,0 +1 @@ +Fixed the documentation of :func:`os.path.normcase` to clarify that on Posix it calls :func:`os.fspath`, which converts path-like objects to `str` or `bytes`.