From 501c06d41ae2b0f3098c1321a2170e71ecae0732 Mon Sep 17 00:00:00 2001 From: barneygale Date: Thu, 25 May 2023 23:04:07 +0100 Subject: [PATCH 1/3] Add failing test. --- Lib/test/test_pathlib.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py index 8b68cdc9b7d003..ef202b751e44e9 100644 --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -904,6 +904,7 @@ def test_eq(self): self.assertEqual(P('a/B'), P('A/b')) self.assertEqual(P('C:a/B'), P('c:A/b')) self.assertEqual(P('//Some/SHARE/a/B'), P('//somE/share/A/b')) + self.assertEqual(P('\u0130'), P('i\u0307')) def test_as_uri(self): P = self.cls From 256e1ee4712c22ad9c52d0cba3eb7f3d93952974 Mon Sep 17 00:00:00 2001 From: barneygale Date: Thu, 25 May 2023 23:04:44 +0100 Subject: [PATCH 2/3] GH-104947: Make pathlib.PureWindowsPath comparisons consistent across OSs Use `str.lower()` rather than `ntpath.normcase()` to normalize case of Windows paths. This restores behaviour from Python 3.11. --- Lib/pathlib.py | 5 ++++- .../Library/2023-05-25-22-54-20.gh-issue-104947.hi6TUr.rst | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2023-05-25-22-54-20.gh-issue-104947.hi6TUr.rst diff --git a/Lib/pathlib.py b/Lib/pathlib.py index fb78939dcc31ba..c8931687a3c6dc 100644 --- a/Lib/pathlib.py +++ b/Lib/pathlib.py @@ -421,7 +421,10 @@ def _str_normcase(self): try: return self._str_normcase_cached except AttributeError: - self._str_normcase_cached = self._flavour.normcase(str(self)) + if _is_case_sensitive(self._flavour): + self._str_normcase_cached = str(self) + else: + self._str_normcase_cached = str(self).lower() return self._str_normcase_cached @property diff --git a/Misc/NEWS.d/next/Library/2023-05-25-22-54-20.gh-issue-104947.hi6TUr.rst b/Misc/NEWS.d/next/Library/2023-05-25-22-54-20.gh-issue-104947.hi6TUr.rst new file mode 100644 index 00000000000000..778b305aae4560 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-05-25-22-54-20.gh-issue-104947.hi6TUr.rst @@ -0,0 +1,2 @@ +Make comparisons between :class:`pathlib.PureWindowsPath` objects consistent +across Windows and Posix. From 93270124de930f678d20713da96235e601202ba2 Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" Date: Fri, 26 May 2023 10:39:29 -0700 Subject: [PATCH 3/3] mention this matches 3.11 behavior in the news entry. --- .../next/Library/2023-05-25-22-54-20.gh-issue-104947.hi6TUr.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2023-05-25-22-54-20.gh-issue-104947.hi6TUr.rst b/Misc/NEWS.d/next/Library/2023-05-25-22-54-20.gh-issue-104947.hi6TUr.rst index 778b305aae4560..4af73d73d2a717 100644 --- a/Misc/NEWS.d/next/Library/2023-05-25-22-54-20.gh-issue-104947.hi6TUr.rst +++ b/Misc/NEWS.d/next/Library/2023-05-25-22-54-20.gh-issue-104947.hi6TUr.rst @@ -1,2 +1,2 @@ Make comparisons between :class:`pathlib.PureWindowsPath` objects consistent -across Windows and Posix. +across Windows and Posix to match 3.11 behavior.