mirror of
https://github.com/python/cpython.git
synced 2025-10-22 17:33:55 +00:00
GH-44626, GH-105476: Fix ntpath.isabs()
handling of part-absolute paths (#113829)
On Windows, `os.path.isabs()` now returns `False` when given a path that starts with exactly one (back)slash. This is more compatible with other functions in `os.path`, and with Microsoft's own documentation. Also adjust `pathlib.PureWindowsPath.is_absolute()` to call `ntpath.isabs()`, which corrects its handling of partial UNC/device paths like `//foo`. Co-authored-by: Jon Foster <jon@jon-foster.co.uk>
This commit is contained in:
parent
dac1da2121
commit
e4ff131e01
9 changed files with 51 additions and 33 deletions
|
@ -1011,10 +1011,14 @@ def test_is_absolute(self):
|
|||
self.assertTrue(P('c:/a').is_absolute())
|
||||
self.assertTrue(P('c:/a/b/').is_absolute())
|
||||
# UNC paths are absolute by definition.
|
||||
self.assertTrue(P('//').is_absolute())
|
||||
self.assertTrue(P('//a').is_absolute())
|
||||
self.assertTrue(P('//a/b').is_absolute())
|
||||
self.assertTrue(P('//a/b/').is_absolute())
|
||||
self.assertTrue(P('//a/b/c').is_absolute())
|
||||
self.assertTrue(P('//a/b/c/d').is_absolute())
|
||||
self.assertTrue(P('//?/UNC/').is_absolute())
|
||||
self.assertTrue(P('//?/UNC/spam').is_absolute())
|
||||
|
||||
def test_join(self):
|
||||
P = self.cls
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue