[Python-checkins] [3.12] GH-104947: Make pathlib.PureWindowsPath comparisons consistent across platforms (GH-104948) (GH-104990)
barneygale
webhook-mailer at python.org
Fri May 26 14:33:17 EDT 2023
https://github.com/python/cpython/commit/eca102ddac77a42c6fda62a283fe0802e0ff5549
commit: eca102ddac77a42c6fda62a283fe0802e0ff5549
branch: 3.12
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: barneygale <barney.gale at gmail.com>
date: 2023-05-26T18:33:09Z
summary:
[3.12] GH-104947: Make pathlib.PureWindowsPath comparisons consistent across platforms (GH-104948) (GH-104990)
Use `str.lower()` rather than `ntpath.normcase()` to normalize case of
Windows paths. This restores behaviour from Python 3.11.
(cherry picked from commit ad0be361c9922a918c7c3eaf83e1d8f2b019279c)
Co-authored-by: Barney Gale <barney.gale at gmail.com>
Co-authored-by: Gregory P. Smith <greg at krypto.org>
files:
A Misc/NEWS.d/next/Library/2023-05-25-22-54-20.gh-issue-104947.hi6TUr.rst
M Lib/pathlib.py
M Lib/test/test_pathlib.py
diff --git a/Lib/pathlib.py b/Lib/pathlib.py
index 3d68c161603d..bfe26e1e1679 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/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py
index ab2c2b232a04..bc2947ec95b3 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
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 000000000000..4af73d73d2a7
--- /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 to match 3.11 behavior.
More information about the Python-checkins
mailing list