Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions Lib/ntpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@ def isabs(s):
sep = b'\\'
altsep = b'/'
colon_sep = b':\\'
double_sep = b'\\\\'
else:
sep = '\\'
altsep = '/'
colon_sep = ':\\'
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)

if s.startswith(sep):
return s.startswith(sep, 1)
else:
return s.startswith(colon_sep, 1)

# Join two (or more) paths.
def join(path, *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`.