mirror of
https://github.com/python/cpython.git
synced 2025-08-07 18:38:38 +00:00
[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 ad0be361c9
)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
This commit is contained in:
parent
dcee0aa911
commit
eca102ddac
3 changed files with 7 additions and 1 deletions
|
@ -421,7 +421,10 @@ class PurePath(object):
|
||||||
try:
|
try:
|
||||||
return self._str_normcase_cached
|
return self._str_normcase_cached
|
||||||
except AttributeError:
|
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
|
return self._str_normcase_cached
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -904,6 +904,7 @@ class PureWindowsPathTest(_BasePurePathTest, unittest.TestCase):
|
||||||
self.assertEqual(P('a/B'), P('A/b'))
|
self.assertEqual(P('a/B'), P('A/b'))
|
||||||
self.assertEqual(P('C:a/B'), P('c: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('//Some/SHARE/a/B'), P('//somE/share/A/b'))
|
||||||
|
self.assertEqual(P('\u0130'), P('i\u0307'))
|
||||||
|
|
||||||
def test_as_uri(self):
|
def test_as_uri(self):
|
||||||
P = self.cls
|
P = self.cls
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Make comparisons between :class:`pathlib.PureWindowsPath` objects consistent
|
||||||
|
across Windows and Posix to match 3.11 behavior.
|
Loading…
Add table
Add a link
Reference in a new issue