pass bytestringed names to fnmatch_all()

Due to `syspath`, fnmatch ends up comparing strings to bytes, so we must
make sure they are bytes. Fixes #2124
This commit is contained in:
Johnny Robeson 2016-07-20 23:32:24 -04:00
parent e7428972ca
commit f87486c1fa

View file

@ -267,7 +267,8 @@ def prune_dirs(path, root=None, clutter=('.DS_Store', 'Thumbs.db')):
# Directory gone already.
continue
clutter = [bytestring_path(c) for c in clutter]
if fnmatch_all(os.listdir(directory), clutter):
match_paths = [bytestring_path(d) for d in os.listdir(directory)]
if fnmatch_all(match_paths, clutter):
# Directory contains only clutter (or nothing).
try:
shutil.rmtree(directory)