mirror of
https://github.com/python/cpython.git
synced 2025-09-02 06:57:58 +00:00
gh-96192: fix os.ismount() to use a path that is str or bytes (GH-96194)
(cherry picked from commit 367f552129
)
Co-authored-by: Christoph Anton Mitterer <calestyo@scientia.org>
Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
Co-authored-by: Eryk Sun <eryksun@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
parent
f4511d3ee9
commit
0076ca48e9
3 changed files with 4 additions and 0 deletions
|
@ -195,6 +195,7 @@ def ismount(path):
|
||||||
if stat.S_ISLNK(s1.st_mode):
|
if stat.S_ISLNK(s1.st_mode):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
path = os.fspath(path)
|
||||||
if isinstance(path, bytes):
|
if isinstance(path, bytes):
|
||||||
parent = join(path, b'..')
|
parent = join(path, b'..')
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -178,6 +178,8 @@ class PosixPathTest(unittest.TestCase):
|
||||||
def test_ismount(self):
|
def test_ismount(self):
|
||||||
self.assertIs(posixpath.ismount("/"), True)
|
self.assertIs(posixpath.ismount("/"), True)
|
||||||
self.assertIs(posixpath.ismount(b"/"), True)
|
self.assertIs(posixpath.ismount(b"/"), True)
|
||||||
|
self.assertIs(posixpath.ismount(FakePath("/")), True)
|
||||||
|
self.assertIs(posixpath.ismount(FakePath(b"/")), True)
|
||||||
|
|
||||||
def test_ismount_non_existent(self):
|
def test_ismount_non_existent(self):
|
||||||
# Non-existent mountpoint.
|
# Non-existent mountpoint.
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fix handling of ``bytes`` :term:`path-like objects <path-like object>` in :func:`os.ismount()`.
|
Loading…
Add table
Add a link
Reference in a new issue