mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
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:
parent
a302a27489
commit
29650fea96
4 changed files with 14 additions and 24 deletions
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue