From 328422ce6162eb18735a2c0de12f8a696be97d0c Mon Sep 17 00:00:00 2001 From: Barney Gale Date: Fri, 26 May 2023 19:05:43 +0100 Subject: GH-103631: Fix `PurePosixPath(PureWindowsPath(...))` separator handling (GH-104949) For backwards compatibility, accept backslashes as path separators in `PurePosixPath` if an instance of `PureWindowsPath` is supplied. This restores behaviour from Python 3.11. Co-authored-by: Gregory P. Smith --- Lib/test/test_pathlib.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Lib/test/test_pathlib.py') diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py index ef202b751e4..01615e20945 100644 --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -789,6 +789,12 @@ class PurePosixPathTest(_BasePurePathTest, unittest.TestCase): pp = P('//a') / '/c' self.assertEqual(pp, P('/c')) + def test_parse_windows_path(self): + P = self.cls + p = P('c:', 'a', 'b') + pp = P(pathlib.PureWindowsPath('c:\\a\\b')) + self.assertEqual(p, pp) + class PureWindowsPathTest(_BasePurePathTest, unittest.TestCase): cls = pathlib.PureWindowsPath -- cgit v1.2.3