diff --git a/beets/mediafile.py b/beets/mediafile.py index dba2be139..27f1bb207 100644 --- a/beets/mediafile.py +++ b/beets/mediafile.py @@ -196,7 +196,7 @@ def _sc_decode(soundcheck): try: soundcheck = soundcheck.replace(' ', '').decode('hex') soundcheck = struct.unpack('!iiiiiiiiii', soundcheck) - except (struct.error, TypeError): + except (struct.error, TypeError, UnicodeEncodeError): # SoundCheck isn't in the format we expect, so return default # values. return 0.0, 0.0 diff --git a/docs/changelog.rst b/docs/changelog.rst index 94d4d52a6..97ec1e66c 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -14,6 +14,8 @@ Fixes: :doc:`/plugins/replaygain`. * :doc:`/plugins/replaygain`: Suppress a deprecation warning emitted by later version of PyGI. +* Fix a crash when reading files whose iTunes SoundCheck tags contain + non-ASCII characters. 1.3.5 (April 15, 2014) @@ -30,7 +32,7 @@ library module. The major new features are: -* Beets can now import `zip`, `tar` and `rar` archives. Just type ``beet +* Beets can now import `zip`, `tar`, and `rar` archives. Just type ``beet import music.zip`` to have beets transparently extract the files to import. * :doc:`/plugins/replaygain`: Added support for calculating ReplayGain values with GStreamer as well the mp3gain program. This enables ReplayGain @@ -43,8 +45,8 @@ The major new features are: In particular, a full complement of features for supporting musical keys are new in this release: -* A new `initial_key` is available in the database and files' tags. You can - set the field manually using a command like ``beet modify +* A new `initial_key` field is available in the database and files' tags. You + can set the field manually using a command like ``beet modify initial_key=Am``. * The :doc:`/plugins/echonest` sets the `initial_key` field if the data is available. diff --git a/test/test_mediafile_edge.py b/test/test_mediafile_edge.py index ad79c6ccc..2a9bccc57 100644 --- a/test/test_mediafile_edge.py +++ b/test/test_mediafile_edge.py @@ -255,6 +255,11 @@ class SoundCheckTest(unittest.TestCase): self.assertEqual(gain, 0.0) self.assertEqual(peak, 0.0) + def test_special_characters(self): + gain, peak = beets.mediafile._sc_decode(u'caf\xe9') + self.assertEqual(gain, 0.0) + self.assertEqual(peak, 0.0) + class ID3v23Test(unittest.TestCase, TestHelper): def _make_test(self, ext='mp3'):