From 546ee2efb3af9c2ba1f11fc41b4e809c92d06972 Mon Sep 17 00:00:00 2001 From: Notorandxor_turing <105069473+NotorandXor256@users.noreply.github.com> Date: Thu, 29 Oct 2026 23:51:35 +0530 Subject: [PATCH 1/4] Edited os.path.normcase docstring to correct Documentation for POSIX systems --- Doc/library/os.path.rst | 2 +- Lib/posixpath.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst index f5ddb426c915f5a..b337ea64dacb016 100644 --- a/Doc/library/os.path.rst +++ b/Doc/library/os.path.rst @@ -415,7 +415,7 @@ 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 (Posix), return the unchanged path .. versionchanged:: 3.6 Accepts a :term:`path-like object`. diff --git a/Lib/posixpath.py b/Lib/posixpath.py index 8025b063397a038..b1bf3f258a77f1d 100644 --- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -52,7 +52,7 @@ 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. Normalizes path-like Objects into Str or Bytes """ return os.fspath(s) From d84fe83bdfaabd576fafe9becfa17e4201dd1634 Mon Sep 17 00:00:00 2001 From: Notorandxor_turing <105069473+NotorandXor256@users.noreply.github.com> Date: Fri, 30 Oct 2026 00:11:51 +0530 Subject: [PATCH 2/4] Fixed normcase doc in os.path.rst --- Doc/library/os.path.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst index b337ea64dacb016..4825093ccfe6d12 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 (Posix), return the unchanged path + On other operating systems (Posix), return String or Bytes converted from + Path-like Object + .. versionchanged:: 3.6 Accepts a :term:`path-like object`. From 7ef5ad7c5c829c5c325cda6da6b01656b00328da Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Thu, 29 Oct 2026 18:57:40 +0000 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Documentation/2026-10-29-18-57-38.gh-issue-160904.nyxAv_.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Documentation/2026-10-29-18-57-38.gh-issue-160904.nyxAv_.rst diff --git a/Misc/NEWS.d/next/Documentation/2026-10-29-18-57-38.gh-issue-160904.nyxAv_.rst b/Misc/NEWS.d/next/Documentation/2026-10-29-18-57-38.gh-issue-160904.nyxAv_.rst new file mode 100644 index 000000000000000..03dd3581b5fce45 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2026-10-29-18-57-38.gh-issue-160904.nyxAv_.rst @@ -0,0 +1 @@ +FiX: In Function os.path.normcase in Lib/posixpath.py docstring states path remains unchanged on POSIX Systems which is not true. Updated Docstring and documentation From f130d3511ec7b198b0fb7017213ca84b92f294fa Mon Sep 17 00:00:00 2001 From: Notorandxor_turing <105069473+NotorandXor256@users.noreply.github.com> Date: Sat, 31 Oct 2026 21:21:10 +0530 Subject: [PATCH 4/4] Fixed py_functools.reduce and added test_reduce.py as test (issue #161004 --- Doc/library/functools.rst | 8 ++++++-- Lib/functools.py | 7 ++++++- Lib/test/test_reduce.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 Lib/test/test_reduce.py diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst index 4eeafad3fbd9156..8f975097a878439 100644 --- a/Doc/library/functools.rst +++ b/Doc/library/functools.rst @@ -476,8 +476,12 @@ The :mod:`!functools` module defines the following functions: value = next(it) else: value = initial - for element in it: - value = function(value, element) + while(True): + try: + element = next(it) + except StopIteration: + break + value = function(value, element) return value See :func:`itertools.accumulate` for an iterator that yields all intermediate diff --git a/Lib/functools.py b/Lib/functools.py index 2c08791d4d2651b..34185660e104d33 100644 --- a/Lib/functools.py +++ b/Lib/functools.py @@ -259,7 +259,12 @@ def reduce(function, sequence, /, initial=_initial_missing): else: value = initial - for element in it: + while(True): + try: + element = next(it) + except StopIteration: + # Stop when no elements are left + break value = function(value, element) return value diff --git a/Lib/test/test_reduce.py b/Lib/test/test_reduce.py new file mode 100644 index 000000000000000..5cddee2fb293a2c --- /dev/null +++ b/Lib/test/test_reduce.py @@ -0,0 +1,28 @@ +import unittest +import operator +import sys +import functools as c_functools + +class Test_reduce(unittest.TestCase): + def test_add_func(self): + del sys.modules['functools'] + sys.modules['_functools'] = None # block the C accelerator + import functools as py_functools + + class Iterator: + def __init__(self): + self.items = [1, 2, 3, 4, 4] + def __next__(self): + if not self.items: + raise StopIteration + return self.items.pop(0) + class Iterable: + def __iter__(self): + return Iterator() + self.assertEqual( + c_functools.reduce(operator.add, Iterable()), + py_functools.reduce(operator.add, Iterable()) + ) + +if __name__ == "__main__": + unittest.main()