From f87486c1fae3ab9d78fd4b39297a421df7ad5543 Mon Sep 17 00:00:00 2001 From: Johnny Robeson Date: Wed, 20 Jul 2016 23:32:24 -0400 Subject: [PATCH] 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 --- beets/util/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/beets/util/__init__.py b/beets/util/__init__.py index 01bd452bc..472f693b6 100644 --- a/beets/util/__init__.py +++ b/beets/util/__init__.py @@ -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)