summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2024-04-17 09:58:19 (GMT)
committerGitHub <noreply@github.com>2024-04-17 09:58:19 (GMT)
commit4e502a4997af4c8042a6ac13115a3f8ba31520ea (patch)
treef72e94e13c5814e8fe32b463c26b5b9964e195c3 /Lib
parent51132da0c4dac13500d9bb86b2fdad42091d3fd9 (diff)
downloadcpython-4e502a4997af4c8042a6ac13115a3f8ba31520ea.zip
cpython-4e502a4997af4c8042a6ac13115a3f8ba31520ea.tar.gz
cpython-4e502a4997af4c8042a6ac13115a3f8ba31520ea.tar.bz2
gh-117394: Speed up os.path.ismount() on Posix (GH-117447)
It is now 2-3 times faster if the user has permissions.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/posixpath.py9
1 files changed, 6 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