gh-86943: implement pathlib.WindowsPath.is_mount() (GH-31458)

Have `pathlib.WindowsPath.is_mount()` call `ntpath.ismount()`. Previously it raised `NotImplementedError` unconditionally.


https://bugs.python.org/issue42777
This commit is contained in:
Barney Gale 2022-08-05 23:37:44 +01:00 committed by GitHub
parent a302a27489
commit 29650fea96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 24 deletions

View file

@ -1211,23 +1211,9 @@ class Path(PurePath):
def is_mount(self):
"""
Check if this path is a POSIX mount point
Check if this path is a mount point
"""
# Need to exist and be a dir
if not self.exists() or not self.is_dir():
return False
try:
parent_dev = self.parent.stat().st_dev
except OSError:
return False
dev = self.stat().st_dev
if dev != parent_dev:
return True
ino = self.stat().st_ino
parent_ino = self.parent.stat().st_ino
return ino == parent_ino
return self._flavour.pathmod.ismount(self)
def is_symlink(self):
"""
@ -1378,6 +1364,3 @@ class WindowsPath(Path, PureWindowsPath):
On a Windows system, instantiating a Path should return this object.
"""
__slots__ = ()
def is_mount(self):
raise NotImplementedError("Path.is_mount() is unsupported on this system")