mirror of
https://github.com/python/cpython.git
synced 2025-09-27 18:59:43 +00:00
[3.12] GH-103631: Fix PurePosixPath(PureWindowsPath(...))
separator handling (GH-104949) (GH-104991)
For backwards compatibility, accept backslashes as path separators in
`PurePosixPath` if an instance of `PureWindowsPath` is supplied.
This restores behaviour from Python 3.11.
(cherry picked from commit 328422ce61
)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
This commit is contained in:
parent
eca102ddac
commit
305d78b714
3 changed files with 11 additions and 0 deletions
|
@ -300,6 +300,9 @@ class PurePath(object):
|
|||
for arg in args:
|
||||
if isinstance(arg, PurePath):
|
||||
path = arg._raw_path
|
||||
if arg._flavour is ntpath and self._flavour is posixpath:
|
||||
# GH-103631: Convert separators for backwards compatibility.
|
||||
path = path.replace('\\', '/')
|
||||
else:
|
||||
try:
|
||||
path = os.fspath(arg)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue