]> granicus.if.org Git - python/commitdiff
Fix #18530. Remove extra stat call from posixpath.ismount
authorBrian Curtin <brian@python.org>
Mon, 22 Jul 2013 18:07:52 +0000 (13:07 -0500)
committerBrian Curtin <brian@python.org>
Mon, 22 Jul 2013 18:07:52 +0000 (13:07 -0500)
Lib/posixpath.py
Misc/NEWS

index e1d59b6e9f3a6a03494aa3cb498c28c74356468b..73624835020a1af165d33136ad3f5e8ccab8dd55 100644 (file)
@@ -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:
index 26c629552f765417e4f4d37cf80ffff57c710e20..3391d2c054c90e8ccfc37358bb87626b4cc9e1b7 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -162,6 +162,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #18530: Remove additional stat call from posixpath.ismount.
+  Patch by Alex Gaynor.
+
 - Issue #18514: Fix unreachable Py_DECREF() call in PyCData_FromBaseObj()
 
 - Issue #9177: Calling read() or write() now raises ValueError, not