]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
#16618: Make glob.glob match consistently across strings and bytes
authorHynek Schlawack <hs@ox.cx>
Thu, 27 Dec 2012 09:20:38 +0000 (10:20 +0100)
committerHynek Schlawack <hs@ox.cx>
Thu, 27 Dec 2012 09:20:38 +0000 (10:20 +0100)
Fixes handling of leading dots.

Patch by Serhiy Storchaka.

1  2 
Lib/glob.py
Misc/NEWS

diff --cc Lib/glob.py
index 33ee43bab132ba98799e7508fbf4d32a59fec442,f16e8e16e420295f201fa59d37f88e00b038c022..c9f811720a4b55a3f8aea0c0716716e4e1e77010
@@@ -55,10 -56,10 +55,10 @@@ def glob1(dirname, pattern)
              dirname = os.curdir
      try:
          names = os.listdir(dirname)
 -    except os.error:
 +    except OSError:
          return []
-     if pattern[0] != '.':
-         names = [x for x in names if x[0] != '.']
+     if not _ishidden(pattern):
+         names = [x for x in names if not _ishidden(x)]
      return fnmatch.filter(names, pattern)
  
  def glob0(dirname, basename):
diff --cc Misc/NEWS
index 72ac2b9834eedf6f7db8cdd67891568bdc79574b,9076810d511f0dcbc085aa3081d41660db64c1bb..1c9f25f34d1d55c4c82ffb96f11f33c2d2c95a54
+++ b/Misc/NEWS
@@@ -190,8 -114,9 +190,11 @@@ Core and Builtin
  Library
  -------
  
+ - Issue #16618: Make glob.glob match consistently across strings and bytes
+   regarding leading dots.  Patch by Serhiy Storchaka.
 +- Issue #16788: Add samestat to Lib/ntpath.py
 +
  - Issue #16702: test_urllib2_localnet tests now correctly ignores proxies for
    localhost tests.