8000 gh-81790: support "UNC" device paths in `ntpath.splitdrive()` by barneygale · Pull Request #91882 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-81790: support "UNC" device paths in ntpath.splitdrive() #91882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jun 10, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add a couple of comments.
  • Loading branch information
barneygale committed Apr 24, 2022
commit 49f9373ad5f2f69d6d15a00e2595bf54c522cfc6
5 changes: 3 additions & 2 deletions Lib/ntpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,14 @@ def splitdrive(p):
unc4 = '\\\\?\\'
unc8 = '\\\\?\\UNC\\'
normp = p.replace(altsep, sep)
offset = 0
if normp[:8] == unc8:
# is a DOS device path with a UNC link, e.g. \\?\UNC\server\share\dir\file
normp = sep * 8 + normp[8:]
offset = 6
elif normp[:4] == unc4:
# is a DOS device path without a UNC link, e.g. \\?\c:\dir\file
offset = 4
else:
offset = 0
if (normp[offset:offset + 2] == unc2) and (normp[offset + 2:offset + 3] != sep):
# is a UNC path:
# vvvvvvvvvvvvvvvvvvvv drive letter or UNC path
Expand Down
0