diff options
author | Brian Curtin <brian@python.org> | 2013-07-22 13:07:52 -0500 |
---|---|---|
committer | Brian Curtin <brian@python.org> | 2013-07-22 13:07:52 -0500 |
commit | 06f6fbffd4a41b4717aa4931580723eb0d98cc81 (patch) | |
tree | 099d62bac97c736570d3a7ec975171c8abbdcb4d /Lib/posixpath.py | |
parent | 7b3902a20fa0f58b11824c2226c30f9cd0e71e88 (diff) | |
download | cpython-git-06f6fbffd4a41b4717aa4931580723eb0d98cc81.tar.gz |
Fix #18530. Remove extra stat call from posixpath.ismount
Diffstat (limited to 'Lib/posixpath.py')
-rw-r--r-- | Lib/posixpath.py | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/Lib/posixpath.py b/Lib/posixpath.py index e1d59b6e9f..7362483502 100644 --- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -182,18 +182,24 @@ def lexists(path): def ismount(path): """Test whether a path is a mount point""" - if islink(path): - # A symlink can never be a mount point - return False try: s1 = os.lstat(path) - if isinstance(path, bytes): - parent = join(path, b'..') - else: - parent = join(path, '..') + except OSError: + # It doesn't exist -- so not a mount point. :-) + return False + else: + if stat.S_ISLNK(s1.st_mode): + return False + + if isinstance(path, bytes): + parent = join(path, b'..') + else: + parent = join(path, '..') + try: s2 = os.lstat(parent) except OSError: - return False # It doesn't exist -- so not a mount point :-) + return False + dev1 = s1.st_dev dev2 = s2.st_dev if dev1 != dev2: |