summaryrefslogtreecommitdiff
path: root/Lib/glob.py
diff options
context:
space:
mode:
authorHynek Schlawack <hs@ox.cx>2012-12-27 10:20:38 +0100
committerHynek Schlawack <hs@ox.cx>2012-12-27 10:20:38 +0100
commit6e5c8f992aa48c3790166f09a7baaa5ed01ca318 (patch)
tree3a47b6dddc1010aa306986f94820cdaddc7154b6 /Lib/glob.py
parent513762fe9c1c241dc1a3b69a3fe81bc90690b03e (diff)
parent6f52027168196a68fc7c37ba1e7d65a16d1e2859 (diff)
downloadcpython-git-6e5c8f992aa48c3790166f09a7baaa5ed01ca318.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 33ee43bab1..c9f811720a 100644
--- a/Lib/glob.py
+++ b/Lib/glob.py
@@ -57,8 +57,8 @@ def glob1(dirname, pattern):
names = os.listdir(dirname)
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):
@@ -82,3 +82,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])