Skip to content

Commit

Permalink
pythonGH-104947: Make pathlib.PureWindowsPath comparisons consistent …
Browse files Browse the repository at this point in the history
…across OSs

Use `str.lower()` rather than `ntpath.normcase()` to normalize case of
Windows paths. This restores behaviour from Python 3.11.
  • Loading branch information
barneygale committed May 25, 2023
1 parent 501c06d commit 256e1ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Lib/pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Make comparisons between :class:`pathlib.PureWindowsPath` objects consistent
across Windows and Posix.

0 comments on commit 256e1ee

Please sign in to comment.