diff --git a/beets/mediafile.py b/beets/mediafile.py index 5010f8797..02befcbb0 100644 --- a/beets/mediafile.py +++ b/beets/mediafile.py @@ -211,9 +211,14 @@ def _pack_asf_image(mime, data, type=3, description=""): # iTunes Sound Check encoding. def _sc_decode(soundcheck): - """Convert a Sound Check string value to a (gain, peak) tuple as + """Convert a Sound Check bytestring value to a (gain, peak) tuple as used by ReplayGain. """ + # We decode binary data. If one of the formats gives us a text + # string, guess that it's UTF-8. + if isinstance(soundcheck, unicode): + soundcheck = soundcheck.decode('utf8') + # SoundCheck tags consist of 10 numbers, each represented by 8 # characters of ASCII hex preceded by a space. try: diff --git a/docs/changelog.rst b/docs/changelog.rst index 3803894b2..349d484b9 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -8,6 +8,7 @@ Fixes: * Fix a problem with the :ref:`stats-cmd` in exact mode when filenames on Windows use non-ASCII characters. :bug:`1891` +* Fix a crash when iTunes Sound Check tags contained invalid data. :bug:`1895` 1.3.17 (February 7, 2016)