[Python-checkins] [3.10] gh-96192: fix os.ismount() to use a path that is str or bytes (GH-96194) (#99456)

JelleZijlstra webhook-mailer at python.org
Sun Jan 22 08:19:16 EST 2023


https://github.com/python/cpython/commit/5717ab3ac50aa91d19c1f44f970e7db92619f2c0
commit: 5717ab3ac50aa91d19c1f44f970e7db92619f2c0
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: JelleZijlstra <jelle.zijlstra at gmail.com>
date: 2023-01-22T05:19:10-08:00
summary:

[3.10] gh-96192: fix os.ismount() to use a path that is str or bytes (GH-96194) (#99456)

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 at christoph.anton.mitterer.name>
Co-authored-by: Christoph Anton Mitterer <calestyo at scientia.org>
Co-authored-by: Eryk Sun <eryksun at gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra at gmail.com>

files:
A Misc/NEWS.d/next/Library/2022-08-23-03-13-18.gh-issue-96192.TJywOF.rst
M Lib/posixpath.py
M Lib/test/test_posixpath.py

diff --git a/Lib/posixpath.py b/Lib/posixpath.py
index 526f017acbd5..e550b470da5b 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 8d398ec01035..50cba256cef0 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 000000000000..58e51da6ba39
--- /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()`.



More information about the Python-checkins mailing list