mirror of
https://github.com/python/cpython.git
synced 2025-11-08 09:32:01 +00:00
[3.13] GH-125069: Fix inconsistent joining in WindowsPath(PosixPath(...)) (GH-125156) (#125409)
`PurePath.__init__()` incorrectly uses the `_raw_paths` of a given
`PurePath` object with a different flavour, even though the procedure to
join path segments can differ between flavours.
This change makes the `_raw_paths`-enabled deferred joining apply _only_
when the path flavours match.
(cherry picked from commit cb8e5995d8)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
parent
cff627a27d
commit
094d95f62c
3 changed files with 15 additions and 2 deletions
|
|
@ -107,6 +107,15 @@ def test_constructor_nested(self):
|
|||
self.assertEqual(P(P('a'), P('b'), P('c')), P(FakePath("a/b/c")))
|
||||
self.assertEqual(P(P('./a:b')), P('./a:b'))
|
||||
|
||||
@needs_windows
|
||||
def test_constructor_nested_foreign_flavour(self):
|
||||
# See GH-125069.
|
||||
p1 = pathlib.PurePosixPath('b/c:\\d')
|
||||
p2 = pathlib.PurePosixPath('b/', 'c:\\d')
|
||||
self.assertEqual(p1, p2)
|
||||
self.assertEqual(self.cls(p1), self.cls('b/c:/d'))
|
||||
self.assertEqual(self.cls(p2), self.cls('b/c:/d'))
|
||||
|
||||
def _check_parse_path(self, raw_path, *expected):
|
||||
sep = self.parser.sep
|
||||
actual = self.cls._parse_path(raw_path.replace('/', sep))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue