Skip to content

Commit 57daeb2

Browse files
committed
Update ismount() to return False if path does not exist when checking for mounted volume
1 parent d0b18b1 commit 57daeb2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Lib/ntpath.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,11 @@ def ismount(path):
290290
return True
291291

292292
if _getvolumepathname:
293-
x = path.rstrip(seps)
294-
y =_getvolumepathname(path).rstrip(seps)
295-
return x.casefold() == y.casefold()
293+
try:
294+
# The path is a mount point if it's a mounted volume.
295+
return path.rstrip(seps).casefold() == _getvolumepathname(path).rstrip(seps).casefold()
296+
except (OSError, FileNotFoundError):
297+
return False
296298
else:
297299
return False
298300

0 commit comments

Comments
 (0)