parent
6a01a2e906
commit
3346778c41
@ -46,6 +46,10 @@ Bug fix release.
|
||||
one. Particularly relevant for Mopidy-Scrobbler users, as before it was
|
||||
essentially unusable. (Fixes: :issue:`1456`, PR: :issue:`1534`)
|
||||
|
||||
- Models: Fix encoding error if :class:`~mopidy.models.fields.Identifier`
|
||||
fields, like the ``musicbrainz_id`` model fields, contained non-ASCII Unicode
|
||||
data. (Fixes: :issue:`1508`, PR: :issue:`1546`)
|
||||
|
||||
- File: Ensure path comparision is done between bytestrings only. Fixes crash
|
||||
where a :confval:`file/media_dirs` path contained non-ASCII characters.
|
||||
(Fixes: :issue:`1345`, PR: :issue:`1493`)
|
||||
|
||||
@ -88,14 +88,17 @@ class Date(String):
|
||||
|
||||
class Identifier(String):
|
||||
"""
|
||||
:class:`Field` for storing ASCII values such as GUIDs or other identifiers.
|
||||
:class:`Field` for storing values such as GUIDs or other identifiers.
|
||||
|
||||
Values will be interned.
|
||||
|
||||
:param default: default value for field
|
||||
"""
|
||||
def validate(self, value):
|
||||
return compat.intern(str(super(Identifier, self).validate(value)))
|
||||
value = super(Identifier, self).validate(value)
|
||||
if isinstance(value, compat.text_type):
|
||||
value = value.encode('utf-8')
|
||||
return compat.intern(value)
|
||||
|
||||
|
||||
class URI(Identifier):
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
# encoding: utf-8
|
||||
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import unittest
|
||||
@ -146,6 +148,11 @@ class IdentifierTest(unittest.TestCase):
|
||||
instance.attr = u'abc'
|
||||
self.assertEqual(u'abc', instance.attr)
|
||||
|
||||
def test_unicode_with_nonascii_allowed(self):
|
||||
instance = create_instance(Identifier())
|
||||
instance.attr = u'æøå'
|
||||
self.assertEqual(u'æøå'.encode('utf-8'), instance.attr)
|
||||
|
||||
def test_other_disallowed(self):
|
||||
instance = create_instance(Identifier())
|
||||
with self.assertRaises(TypeError):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user