[Python-checkins] cpython (2.7): Issue #17923: glob() patterns ending with a slash no longer match non-dirs on

serhiy.storchaka python-checkins at python.org
Tue Aug 12 11:58:29 CEST 2014


http://hg.python.org/cpython/rev/e430973149ed
changeset:   92078:e430973149ed
branch:      2.7
parent:      92073:97ed0b51bbc0
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Tue Aug 12 12:54:55 2014 +0300
summary:
  Issue #17923: glob() patterns ending with a slash no longer match non-dirs on
AIX.  Based on patch by Delhallt.

files:
  Lib/glob.py |  11 ++++++++---
  Misc/NEWS   |   3 +++
  2 files changed, 11 insertions(+), 3 deletions(-)


diff --git a/Lib/glob.py b/Lib/glob.py
--- a/Lib/glob.py
+++ b/Lib/glob.py
@@ -35,11 +35,16 @@
     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
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -19,6 +19,9 @@
 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.

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list