diff --git a/Lib/posixpath.py b/Lib/posixpath.py index 5e1ebe3293d849a5aad4aea24da283ae570913af..5b4d78bca0613213acbf1f1660e9c5bd27347850 100644 --- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -195,6 +195,7 @@ def ismount(path): if stat.S_ISLNK(s1.st_mode): return False + path = os.fspath(path) if isinstance(path, bytes): parent = join(path, b'..') else: diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py index c644f881e460fedce631664a4f336f1e74a472b1..8a1dd131928cffd7ba59d69126145a6ea110cfe7 100644 --- a/Lib/test/test_posixpath.py +++ b/Lib/test/test_posixpath.py @@ -178,6 +178,8 @@ def test_islink(self): def test_ismount(self): self.assertIs(posixpath.ismount("/"), 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): # Non-existent mountpoint. diff --git a/Misc/NEWS.d/next/Library/2022-08-23-03-13-18.gh-issue-96192.TJywOF.rst b/Misc/NEWS.d/next/Library/2022-08-23-03-13-18.gh-issue-96192.TJywOF.rst new file mode 100644 index 0000000000000000000000000000000000000000..58e51da6ba39930aa1d78097577a6d2c4aafda82 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-08-23-03-13-18.gh-issue-96192.TJywOF.rst @@ -0,0 +1 @@ +Fix handling of ``bytes`` :term:`path-like objects <path-like object>` in :func:`os.ismount()`.