diff --git a/Lib/pathlib.py b/Lib/pathlib.py --- a/Lib/pathlib.py +++ b/Lib/pathlib.py @@ -180,7 +180,9 @@ if not s: return os.getcwd() if _getfinalpathname is not None: - return self._ext_to_normal(_getfinalpathname(s)) + keep_ext_prefix = bool(self._split_extended_path(s)[0]) + s = _getfinalpathname(s) + return s if keep_ext_prefix else self._ext_to_normal(s) # Means fallback on absolute return None diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -1879,6 +1879,12 @@ p = P(BASE, "dirC") self.assertEqual(set(p.rglob("FILEd")), { P(BASE, "dirC/dirD/fileD") }) + def test_resolve_ext_prefix(self): + P = self.cls + p = P(BASE) + self.assertEqual(BASE, str(p.resolve())) + p = P(pathlib._windows_flavour.ext_namespace_prefix + BASE) + self.assertEqual("\\\\?\\" + BASE, str(p.resolve())) if __name__ == "__main__": unittest.main()