mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
#16618: Make glob.glob match consistently across strings and bytes
Fixes handling of leading dots. Patch by Serhiy Storchaka.
This commit is contained in:
commit
6e5c8f992a
3 changed files with 59 additions and 30 deletions
|
@ -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])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue