]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.10] 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>
Sun, 22 Jan 2023 13:19:10 +0000 (05:19 -0800)
committerGitHub <noreply@github.com>
Sun, 22 Jan 2023 13:19:10 +0000 (05:19 -0800)
gh-96192: fix os.ismount() to use a path that is str or bytes (GH-96194)
(cherry picked from commit 367f552129341796d75fc4cc40edb49405235a2b)

Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
Co-authored-by: Christoph Anton Mitterer <calestyo@scientia.org>
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 526f017acbd5f13c717458867d3e06803054bf2e..e550b470da5bebf60cf2ea4efc2b017520e5d670 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 8d398ec0103544555d9502c83243cc870ba485e1..50cba256cef039daeeccd2f41211246512fc2430 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()`.