]> granicus.if.org Git - python/commitdiff
Issue #17923: glob() patterns ending with a slash no longer match non-dirs on
authorSerhiy Storchaka <storchaka@gmail.com>
Tue, 12 Aug 2014 09:54:55 +0000 (12:54 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Tue, 12 Aug 2014 09:54:55 +0000 (12:54 +0300)
AIX.  Based on patch by Delhallt.

Lib/glob.py
Misc/NEWS

index f34534b53c44825f010fd757aaf68cd93132cd5a..b3d9ec1b1f8a36162d69c908f6a6948de94def7d 100644 (file)
@@ -35,11 +35,16 @@ def iglob(pathname):
     patterns.
 
     """
+    dirname, basename = os.path.split(pathname)
     if not has_magic(pathname):
-        if os.path.lexists(pathname):
-            yield pathname
+        if basename:
+            if os.path.lexists(pathname):
+                yield pathname
+        else:
+            # Patterns ending with a slash should match only directories
+            if os.path.isdir(dirname):
+                yield pathname
         return
-    dirname, basename = os.path.split(pathname)
     if not dirname:
         for name in glob1(os.curdir, basename):
             yield name
index 222d928c3a1c5a9946a689a7de4dbef262f9a06d..fc8826936ddd71971ea191c841c34b14f7b97bdc 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -19,6 +19,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #17923: glob() patterns ending with a slash no longer match non-dirs on
+  AIX.  Based on patch by Delhallt.
+
 - Issue #21975: Fixed crash when using uninitialized sqlite3.Row (in particular
   when unpickling pickled sqlite3.Row).  sqlite3.Row is now initialized in the
   __new__() method.