Bug report
Bug description:
On Windows, os.path.ismount() (ntpath.ismount()) returns True for UNC paths that have a server but no share component. A UNC mount point requires both a server and a share (\\server\share); a bare server name is not a mount point and should return False.
# Python 3.16.0a0 (current main, MSC v.1944 64-bit)
>>> import os.path
>>> os.path.ismount(r"\\server") # server, no share
True
>>> os.path.ismount(r"\\?\UNC\server") # extended UNC, server, no share
True
Genuine share roots correctly return True:
>>> os.path.ismount(r"\\server\share")
True
>>> os.path.ismount(r"\\?\UNC\server\share")
True
This is partly a regression. On 3.11:
>>> os.path.ismount(r"\\?\UNC\server")
False
>>> os.path.ismount(r"\\server")
OSError: [WinError 123] ...
So \\?\UNC\server changed from False to True. (The same change correctly fixed \\?\UNC\server\share, which was wrongly False on 3.11.)
Root cause:
Since the splitroot()-based rewrite in gh-101000, ismount does if drive and drive[0] in seps: return not rest. For an incomplete one-component UNC, splitroot(r"\\server") returns ('\\server', '', '') — the whole thing lands in drive with an empty tail — so it passes the share-root check despite there being no share.
Suggested fix:
Require both a server and a share component before treating a UNC drive as a mount root.
Split off from #139916 per @zooba's suggestion.
CPython versions tested on:
3.11, CPython main (3.16.0a0)
Operating systems tested on:
Windows
Linked PRs
Bug report
Bug description:
On Windows,
os.path.ismount()(ntpath.ismount()) returnsTruefor UNC paths that have a server but no share component. A UNC mount point requires both a server and a share (\\server\share); a bare server name is not a mount point and should returnFalse.Genuine share roots correctly return
True:This is partly a regression. On 3.11:
So
\\?\UNC\serverchanged fromFalsetoTrue. (The same change correctly fixed\\?\UNC\server\share, which was wronglyFalseon 3.11.)Root cause:
Since the
splitroot()-based rewrite in gh-101000,ismountdoesif drive and drive[0] in seps: return not rest. For an incomplete one-component UNC,splitroot(r"\\server")returns('\\server', '', '')— the whole thing lands indrivewith an emptytail— so it passes the share-root check despite there being no share.Suggested fix:
Require both a server and a share component before treating a UNC
driveas a mount root.Split off from #139916 per @zooba's suggestion.
CPython versions tested on:
3.11, CPython main (3.16.0a0)
Operating systems tested on:
Windows
Linked PRs