diff options
author | Hynek Schlawack <hs@ox.cx> | 2012-12-27 09:20:38 (GMT) |
---|---|---|
committer | Hynek Schlawack <hs@ox.cx> | 2012-12-27 09:20:38 (GMT) |
commit | 6e5c8f992aa48c3790166f09a7baaa5ed01ca318 (patch) | |
tree | 3a47b6dddc1010aa306986f94820cdaddc7154b6 /Lib/glob.py | |
parent | 513762fe9c1c241dc1a3b69a3fe81bc90690b03e (diff) | |
parent | 6f52027168196a68fc7c37ba1e7d65a16d1e2859 (diff) | |
download | cpython-6e5c8f992aa48c3790166f09a7baaa5ed01ca318.zip cpython-6e5c8f992aa48c3790166f09a7baaa5ed01ca318.tar.gz cpython-6e5c8f992aa48c3790166f09a7baaa5ed01ca318.tar.bz2 |
#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.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/glob.py b/Lib/glob.py index 33ee43b..c9f8117 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]) |