# Buggy code
def validate(self, value):
    return compat.intern(str(super(Identifier, self).validate(value)))


# Traceback (UnicodeEncodeError)
INFO     Scanned 3500 of 5494 files in 25s, ~14s left.
ERROR    'ascii' codec can't encode character u'\ufeff' in position 0: ordinal not in range(128)
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/mopidy/__main__.py", line 134, in main
return args.command.run(args, proxied_config)
File "/usr/local/lib/python2.7/site-packages/mopidy/local/commands.py", line 150, in run
track = tags.convert_tags_to_track(result.tags).replace(
File "/usr/local/lib/python2.7/site-packages/mopidy/audio/tags.py", line 81, in convert_tags_to_track
'musicbrainz-sortname')
File "/usr/local/lib/python2.7/site-packages/mopidy/audio/tags.py", line 137, in _artists
return [Artist(**attrs)]
File "/usr/local/lib/python2.7/site-packages/mopidy/models/immutable.py", line 158, in __call__
*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/mopidy/models/immutable.py", line 34, in __init__
self._set_field(key, value)
File "/usr/local/lib/python2.7/site-packages/mopidy/models/immutable.py", line 186, in _set_field
object.__setattr__(self, name, value)
File "/usr/local/lib/python2.7/site-packages/mopidy/models/fields.py", line 50, in __set__
value = self.validate(value)
File "/usr/local/lib/python2.7/site-packages/mopidy/models/fields.py", line 98, in validate
return compat.intern(str(super(Identifier, self).validate(value)))
UnicodeEncodeError: 'ascii' codec can't encode character u'\ufeff' in position 0: ordinal not in range(128)
Traceback (most recent call last):
File "/usr/local/bin/mopidy", line 9, in <module>
load_entry_point('Mopidy==2.0.0', 'console_scripts', 'mopidy')()
File "/usr/local/lib/python2.7/site-packages/mopidy/__main__.py", line 134, in main
return args.command.run(args, proxied_config)
File "/usr/local/lib/python2.7/site-packages/mopidy/local/commands.py", line 150, in run
track = tags.convert_tags_to_track(result.tags).replace(
File "/usr/local/lib/python2.7/site-packages/mopidy/audio/tags.py", line 81, in convert_tags_to_track
'musicbrainz-sortname')
File "/usr/local/lib/python2.7/site-packages/mopidy/audio/tags.py", line 137, in _artists
return [Artist(**attrs)]
File "/usr/local/lib/python2.7/site-packages/mopidy/models/immutable.py", line 158, in __call__
*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/mopidy/models/immutable.py", line 34, in __init__
self._set_field(key, value)
File "/usr/local/lib/python2.7/site-packages/mopidy/models/immutable.py", line 186, in _set_field
object.__setattr__(self, name, value)
File "/usr/local/lib/python2.7/site-packages/mopidy/models/fields.py", line 50, in __set__
value = self.validate(value)
File "/usr/local/lib/python2.7/site-packages/mopidy/models/fields.py", line 98, in validate
return compat.intern(str(super(Identifier, self).validate(value)))
UnicodeEncodeError: 'ascii' codec can't encode character u'\ufeff' in position 0: ordinal not in range(128)

# Fixed code
def validate(self, value):
    value = super(Identifier, self).validate(value)
    if isinstance(value, compat.text_type):
        value = value.encode("utf-8")
    return compat.intern(value)