diff --git a/beets/library.py b/beets/library.py index ef97161a6..8e6f75c1c 100644 --- a/beets/library.py +++ b/beets/library.py @@ -1135,6 +1135,9 @@ class Library(BaseLibrary): # Preserve extension. _, extension = pathmod.splitext(item.path) + if fragment: + # Outputting Unicode. + extension = extension.decode('utf8', 'ignore') subpath += extension.lower() if fragment: diff --git a/docs/changelog.rst b/docs/changelog.rst index 20d7a9877..00b409baa 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -27,6 +27,8 @@ Changelog disagree. * Fix a bug that caused the :doc:`/plugins/lastgenre` and other plugins not to modify files' tags even when they successfully change the database. +* Fix a VFS bug leading to a crash in the :doc:`/plugins/bpd` when files had + non-ASCII extensions. .. _Tomahawk resolver: http://beets.radbox.org/blog/tomahawk-resolver.html diff --git a/test/test_db.py b/test/test_db.py index 49a1dbef5..fc597b6cd 100644 --- a/test/test_db.py +++ b/test/test_db.py @@ -442,6 +442,12 @@ class DestinationTest(unittest.TestCase): finally: sys.getfilesystemencoding = oldfunc + def test_unicode_extension_in_fragment(self): + self.lib.path_formats = [('default', u'foo')] + self.i.path = util.bytestring_path(u'bar.caf\xe9') + dest = self.lib.destination(self.i, platform='linux2', fragment=True) + self.assertEqual(dest, u'foo.caf\xe9') + class PathFormattingMixin(object): """Utilities for testing path formatting.""" def _setf(self, fmt):