diff options
-rw-r--r-- | Lib/posixpath.py | 9 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2024-04-02-11-17-44.gh-issue-117394.2aoSlb.rst | 1 |
2 files changed, 7 insertions, 3 deletions
diff --git a/Lib/posixpath.py b/Lib/posixpath.py index 11cbaca..79cda50 100644 --- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -206,11 +206,14 @@ def ismount(path): parent = join(path, b'..') else: parent = join(path, '..') - parent = realpath(parent) try: s2 = os.lstat(parent) - except (OSError, ValueError): - return False + except OSError: + parent = realpath(parent) + try: + s2 = os.lstat(parent) + except OSError: + return False # path/.. on a different device as path or the same i-node as path return s1.st_dev != s2.st_dev or s1.st_ino == s2.st_ino diff --git a/Misc/NEWS.d/next/Library/2024-04-02-11-17-44.gh-issue-117394.2aoSlb.rst b/Misc/NEWS.d/next/Library/2024-04-02-11-17-44.gh-issue-117394.2aoSlb.rst new file mode 100644 index 0000000..7b695be --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-04-02-11-17-44.gh-issue-117394.2aoSlb.rst @@ -0,0 +1 @@ +:func:`os.path.ismount` is now 2-3 times faster if the user has permissions. |