From 68f093f17452ce459e1d5c065ebb1c6c9db1f042 Mon Sep 17 00:00:00 2001 From: GUOZIJAN Date: Fri, 30 Oct 2026 00:59:06 +0800 Subject: [PATCH 1/2] gh-160904: Correct os.path.normcase documentation for POSIX os.path.normcase does not do nothing on POSIX: it calls os.fspath, which normalizes path-like objects to str or bytes. Say so in the docstring and in the documentation, instead of claiming that the path is returned unchanged. --- Doc/library/os.path.rst | 4 +++- Lib/posixpath.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst index f5ddb426c915f5a..672f4dc8adb1751 100644 --- a/Doc/library/os.path.rst +++ b/Doc/library/os.path.rst @@ -415,7 +415,9 @@ 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, do not change the case of the path, but + normalize :term:`path-like objects ` to :class:`str` or + :class:`bytes`, just like :func:`os.fspath`. .. versionchanged:: 3.6 Accepts a :term:`path-like object`. diff --git a/Lib/posixpath.py b/Lib/posixpath.py index 8025b063397a038..aed0f0a271b5289 100644 --- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -52,7 +52,8 @@ 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. Does not change the case, but + normalizes path-like objects to str or bytes, like os.fspath""" return os.fspath(s) From c37b869857308b02bacbd8ddfdede8fac1be5046 Mon Sep 17 00:00:00 2001 From: GUOZIJAN Date: Fri, 30 Oct 2026 02:27:03 +0800 Subject: [PATCH 2/2] gh-160904: Add news entry --- .../Documentation/2026-10-30-02-30-00.gh-issue-160904.iZKPFG.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Documentation/2026-10-30-02-30-00.gh-issue-160904.iZKPFG.rst diff --git a/Misc/NEWS.d/next/Documentation/2026-10-30-02-30-00.gh-issue-160904.iZKPFG.rst b/Misc/NEWS.d/next/Documentation/2026-10-30-02-30-00.gh-issue-160904.iZKPFG.rst new file mode 100644 index 000000000000000..ec88e9841d00360 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2026-10-30-02-30-00.gh-issue-160904.iZKPFG.rst @@ -0,0 +1 @@ +Clarify :func:`os.path.normcase` documentation: on POSIX it normalizes path-like objects via :func:`os.fspath` rather than returning the path unchanged.