Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/ntpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def isabs(s):
double_sep = '\\\\'
s = s[:3].replace(altsep, sep)
# Absolute: UNC, device, and paths with a drive and root.
return s.startswith(colon_sep, 1) or s.startswith(double_sep)
return (s[1:3] == colon_sep and s[:1] != sep) or s[:2] == double_sep


# Join two (or more) paths.
Expand Down
3 changes: 2 additions & 1 deletion Lib/test/test_ntpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,12 @@ def test_isabs(self):
tester('ntpath.isabs("c:/foo/bar")', 1)
tester('ntpath.isabs("\\\\conky\\mountpoint\\")', 1)

# gh-44626: paths with only a drive or root are not absolute.
# gh-44626 & gh-117352: paths with only a drive or root are not absolute.
tester('ntpath.isabs("\\foo\\bar")', 0)
tester('ntpath.isabs("/foo/bar")', 0)
tester('ntpath.isabs("c:foo\\bar")', 0)
tester('ntpath.isabs("c:foo/bar")', 0)
tester('ntpath.isabs("/:/foo/bar")', 0)

# gh-96290: normal UNC paths and device paths without trailing backslashes
tester('ntpath.isabs("\\\\conky\\mountpoint")', 1)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Handle ``/:`` for :func:`ntpath.isabs`.