Skip to content

Commit eca102d

Browse files
miss-islingtonbarneygalegpshead
authored
[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 ad0be36) Co-authored-by: Barney Gale <barney.gale@gmail.com> Co-authored-by: Gregory P. Smith <greg@krypto.org>
1 parent dcee0aa commit eca102d

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

Lib/pathlib.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,10 @@ def _str_normcase(self):
421421
try:
422422
return self._str_normcase_cached
423423
except AttributeError:
424-
self._str_normcase_cached = self._flavour.normcase(str(self))
424+
if _is_case_sensitive(self._flavour):
425+
self._str_normcase_cached = str(self)
426+
else:
427+
self._str_normcase_cached = str(self).lower()
425428
return self._str_normcase_cached
426429

427430
@property

Lib/test/test_pathlib.py

+1
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,7 @@ def test_eq(self):
904904
self.assertEqual(P('a/B'), P('A/b'))
905905
self.assertEqual(P('C:a/B'), P('c:A/b'))
906906
self.assertEqual(P('//Some/SHARE/a/B'), P('//somE/share/A/b'))
907+
self.assertEqual(P('\u0130'), P('i\u0307'))
907908

908909
def test_as_uri(self):
909910
P = self.cls
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Make comparisons between :class:`pathlib.PureWindowsPath` objects consistent
2+
across Windows and Posix to match 3.11 behavior.

0 commit comments

Comments
 (0)