Skip to content

Commit 256e1ee

Browse files
committed
pythonGH-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.
1 parent 501c06d commit 256e1ee

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎Lib/pathlib.py‎

Lines changed: 4 additions & 1 deletion
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
Lines changed: 2 additions & 0 deletions
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.

0 commit comments

Comments
 (0)