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
5 changes: 4 additions & 1 deletion Lib/ntpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,10 @@ def ismount(path):
return True

if _getvolumepathname:
return path.rstrip(seps) == _getvolumepathname(path).rstrip(seps)
try:
return path.rstrip(seps) == _getvolumepathname(path).rstrip(seps)
except OSError:
return False
else:
return False

Expand Down
8 changes: 8 additions & 0 deletions Lib/test/test_ntpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,14 @@ def test_ismount(self):
self.assertTrue(ntpath.ismount(b"\\\\.\\c:\\"))
self.assertTrue(ntpath.ismount(b"\\\\.\\C:\\"))

for drive in "DEFGHIJKLMNOPQRSTUVWXYZ":
if not ntpath.exists(drive + ":\\"):
self.assertFalse(ntpath.ismount(drive + ":\\NotExist"))
break
else:
if support.verbose:
print("No missing drive found to test 'ismount'")

with support.temp_dir() as d:
self.assertFalse(ntpath.ismount(d))

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Ensure `ismount` return False instead of raising `FileNotFoundError`
when `path` is under a drive that doesn't exist.