mirror of
https://github.com/python/cpython.git
synced 2025-08-10 03:49:18 +00:00
GH-125069: Fix inconsistent joining in WindowsPath(PosixPath(...))
(#125156)
`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. Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
parent
c6d7b644c2
commit
cb8e5995d8
3 changed files with 15 additions and 2 deletions
|
@ -119,9 +119,9 @@ class PurePath(PurePathBase):
|
|||
paths = []
|
||||
for arg in args:
|
||||
if isinstance(arg, PurePath):
|
||||
if arg.parser is ntpath and self.parser is posixpath:
|
||||
if arg.parser is not self.parser:
|
||||
# GH-103631: Convert separators for backwards compatibility.
|
||||
paths.extend(path.replace('\\', '/') for path in arg._raw_paths)
|
||||
paths.append(arg.as_posix())
|
||||
else:
|
||||
paths.extend(arg._raw_paths)
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue