summaryrefslogtreecommitdiff
path: root/Lib/glob.py
diff options
context:
space:
mode:
authorHynek Schlawack <hs@ox.cx>2012-12-27 10:15:53 +0100
committerHynek Schlawack <hs@ox.cx>2012-12-27 10:15:53 +0100
commit6f52027168196a68fc7c37ba1e7d65a16d1e2859 (patch)
tree8c2bb4c87ce611d69b2627eaf88f1a9e0e193104 /Lib/glob.py
parentb172697cd8493f433c577a71433f198e0ca471c8 (diff)
parente26568f81244e3fb62ab07fd0a3405a99ee87895 (diff)
downloadcpython-git-6f52027168196a68fc7c37ba1e7d65a16d1e2859.tar.gz
#16618: Make glob.glob match consistently across strings and bytes
Fixes handling of leading dots. Patch by Serhiy Storchaka.
Diffstat (limited to 'Lib/glob.py')
-rw-r--r--Lib/glob.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/glob.py b/Lib/glob.py
index 58888d64b5..f16e8e16e4 100644
--- a/Lib/glob.py
+++ b/Lib/glob.py
@@ -58,8 +58,8 @@ def glob1(dirname, pattern):
names = os.listdir(dirname)
except os.error:
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):
@@ -83,3 +83,6 @@ def has_magic(s):
else:
match = magic_check.search(s)
return match is not None
+
+def _ishidden(path):
+ return path[0] in ('.', b'.'[0])