]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-96192: fix os.ismount() to use a path that is str or bytes (GH-96194)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 30 Nov 2022 23:31:49 +0000 (15:31 -0800)
committerGitHub <noreply@github.com>
Wed, 30 Nov 2022 23:31:49 +0000 (15:31 -0800)
(cherry picked from commit 367f552129341796d75fc4cc40edb49405235a2b)

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>
Lib/posixpath.py
Lib/test/test_posixpath.py
Misc/NEWS.d/next/Library/2022-08-23-03-13-18.gh-issue-96192.TJywOF.rst [new file with mode: 0644]

index 5e1ebe3293d849a5aad4aea24da283ae570913af..5b4d78bca0613213acbf1f1660e9c5bd27347850 100644 (file)
@@ -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:
index c644f881e460fedce631664a4f336f1e74a472b1..8a1dd131928cffd7ba59d69126145a6ea110cfe7 100644 (file)
@@ -178,6 +178,8 @@ class PosixPathTest(unittest.TestCase):
     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 (file)
index 0000000..58e51da
--- /dev/null
@@ -0,0 +1 @@
+Fix handling of ``bytes`` :term:`path-like objects <path-like object>` in :func:`os.ismount()`.