diff options
author | Barney Gale <barney.gale@gmail.com> | 2022-06-10 15:59:55 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-10 15:59:55 (GMT) |
commit | 2ba0fd5767577954f331ecbd53596cd8035d7186 (patch) | |
tree | 23944b62d578a05d81812165fec1f994637b72f9 /Lib/ntpath.py | |
parent | 53a8b17895e91d08f76a2fb59a555d012cd85ab4 (diff) | |
download | cpython-2ba0fd5767577954f331ecbd53596cd8035d7186.zip cpython-2ba0fd5767577954f331ecbd53596cd8035d7186.tar.gz cpython-2ba0fd5767577954f331ecbd53596cd8035d7186.tar.bz2 |
gh-81790: support "UNC" device paths in `ntpath.splitdrive()` (GH-91882)
Diffstat (limited to 'Lib/ntpath.py')
-rw-r--r-- | Lib/ntpath.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/ntpath.py b/Lib/ntpath.py index 73b1bd1..959bcd0 100644 --- a/Lib/ntpath.py +++ b/Lib/ntpath.py @@ -172,17 +172,23 @@ def splitdrive(p): sep = b'\\' altsep = b'/' colon = b':' + unc_prefix = b'\\\\?\\UNC' else: sep = '\\' altsep = '/' colon = ':' + unc_prefix = '\\\\?\\UNC' normp = p.replace(altsep, sep) if (normp[0:2] == sep*2) and (normp[2:3] != sep): # is a UNC path: # vvvvvvvvvvvvvvvvvvvv drive letter or UNC path # \\machine\mountpoint\directory\etc\... # directory ^^^^^^^^^^^^^^^ - index = normp.find(sep, 2) + if normp[:8].upper().rstrip(sep) == unc_prefix: + start = 8 + else: + start = 2 + index = normp.find(sep, start) if index == -1: return p[:0], p index2 = normp.find(sep, index + 1) |