fix #705: unicode in SoundCheck fields

This commit is contained in:
Adrian Sampson 2014-04-17 18:10:16 -07:00
parent bd047ec6c8
commit 309c5c1a58
3 changed files with 11 additions and 4 deletions

View file

@ -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

View file

@ -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.

View file

@ -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'):