# Buggy code
def parse_urilist(data):
    result = []
    for line in data.splitlines():
        if not line.strip() or line.startswith("#"):
            continue
        try:
            validation.check_uri(line)
        except ValueError:
            return []
        result.append(line)
    return result


# Traceback (UnicodeDecodeError)
INFO     2015-08-22 22:19:26,991 [855:MpdSession-31] mopidy.mpd.session
New MPD connection from [::ffff:127.0.0.1]:50701
DEBUG    2015-08-22 22:19:26,993 [855:MpdSession-31] mopidy.mpd.session
Request from [::ffff:127.0.0.1]:50701: command_list_begin
DEBUG    2015-08-22 22:19:26,993 [855:MpdSession-31] mopidy.mpd.session
Request from [::ffff:127.0.0.1]:50701: add "http://feedproxy.google.com/~r/WelcomeToNightVale/~5/tXeJa4IGs-8/23-EternalScouts.mp3"
DEBUG    2015-08-22 22:19:26,994 [855:MpdSession-31] mopidy.mpd.session
Request from [::ffff:127.0.0.1]:50701: play "0"
DEBUG    2015-08-22 22:19:26,994 [855:MpdSession-31] mopidy.mpd.session
Request from [::ffff:127.0.0.1]:50701: command_list_end
DEBUG    2015-08-22 22:19:28,176 [855:Core-27] mopidy.core.tracklist
Triggering event: tracklist_changed()
DEBUG    2015-08-22 22:19:28,177 [855:MainThread] mopidy.listener
Sending tracklist_changed to CoreListener: {}
DEBUG    2015-08-22 22:19:28,177 [855:Core-27] mopidy.core.playback
Changing state: stopped -> playing
DEBUG    2015-08-22 22:19:28,177 [855:Core-27] mopidy.core.playback
Triggering playback state change event
DEBUG    2015-08-22 22:19:28,179 [855:MainThread] mopidy.listener
Sending playback_state_changed to CoreListener: {'old_state': u'stopped', 'new_state': u'playing'}
DEBUG    2015-08-22 22:19:28,179 [855:Audio-2] mopidy.audio.gst
State change to GST_STATE_READY: result=GST_STATE_CHANGE_SUCCESS
DEBUG    2015-08-22 22:19:28,179 [855:MainThread] mopidy.audio.gst
Got state-changed message: old=GST_STATE_NULL new=GST_STATE_READY     pending=GST_STATE_VOID_PENDING
INFO     2015-08-22 22:19:34,545 [855:MpdSession-32] mopidy.mpd.session
New MPD connection from [::ffff:127.0.0.1]:50713
DEBUG    2015-08-22 22:19:34,547 [855:MpdSession-32] mopidy.mpd.session
Request from [::ffff:127.0.0.1]:50713: status
ERROR    2015-08-22 22:19:38,324 [855:MpdSession-31] pykka
Unhandled exception in MpdSession (urn:uuid:8a894042-6120-4236-a944-cd336bd7c8b3):
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/pykka/actor.py", line 201, in _actor_loop
response = self._handle_receive(message)
File "/usr/local/lib/python2.7/site-packages/pykka/actor.py", line 304, in _handle_receive
return self.on_receive(message)
File "/usr/local/lib/python2.7/site-packages/mopidy/internal/network.py", line 370, in on_receive
self.on_line_received(line)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/session.py", line 34, in on_line_received
response = self.dispatcher.handle_request(line)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 47, in handle_request
return self._call_next_filter(request, response, filter_chain)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 68, in _call_next_filter
return next_filter(request, response, filter_chain)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 76, in     _catch_mpd_ack_errors_filter
return self._call_next_filter(request, response, filter_chain)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 68, in _call_next_filter
return next_filter(request, response, filter_chain)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 86, in _authenticate_filter
return self._call_next_filter(request, response, filter_chain)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 68, in _call_next_filter
return next_filter(request, response, filter_chain)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 105, in _command_list_filter
response = self._call_next_filter(request, response, filter_chain)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 68, in _call_next_filter
return next_filter(request, response, filter_chain)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 134, in _idle_filter
response = self._call_next_filter(request, response, filter_chain)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 68, in _call_next_filter
return next_filter(request, response, filter_chain)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 147, in _add_ok_filter
response = self._call_next_filter(request, response, filter_chain)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 68, in _call_next_filter
return next_filter(request, response, filter_chain)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 159, in _call_handler_filter
response = self._format_response(self._call_handler(request))
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 174, in _call_handler
return protocol.commands.call(tokens, context=self.context)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/protocol/__init__.py", line 180, in call
return self.handlers[tokens[0]](context, *tokens[1:])
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/protocol/__init__.py", line 158, in validate
return func(**callargs)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/protocol/command_list.py", line 42, in command_list_end
command, current_command_list_index=index)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 47, in handle_request
return self._call_next_filter(request, response, filter_chain)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 68, in _call_next_filter
return next_filter(request, response, filter_chain)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 76, in _catch_mpd_ack_errors_filter
return self._call_next_filter(request, response, filter_chain)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 68, in _call_next_filter
return next_filter(request, response, filter_chain)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 86, in _authenticate_filter
return self._call_next_filter(request, response, filter_chain)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 68, in _call_next_filter
return next_filter(request, response, filter_chain)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 105, in _command_list_filter
response = self._call_next_filter(request, response, filter_chain)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 68, in _call_next_filter
return next_filter(request, response, filter_chain)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 134, in _idle_filter
response = self._call_next_filter(request, response, filter_chain)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 68, in _call_next_filter
return next_filter(request, response, filter_chain)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 147, in _add_ok_filter
response = self._call_next_filter(request, response, filter_chain)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 68, in _call_next_filter
return next_filter(request, response, filter_chain)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 159, in _call_handler_filter
response = self._format_response(self._call_handler(request))
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 174, in _call_handler
return protocol.commands.call(tokens, context=self.context)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/protocol/__init__.py", line 180, in call
return self.handlers[tokens[0]](context, *tokens[1:])
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/protocol/__init__.py", line 158, in validate
return func(**callargs)
File "/usr/local/lib/python2.7/site-packages/mopidy/mpd/protocol/playback.py", line 181, in play
return context.core.playback.play(tl_track).get()
File "/usr/local/lib/python2.7/site-packages/pykka/threading.py", line 52, in get
compat.reraise(*self._data['exc_info'])
File "/usr/local/lib/python2.7/site-packages/pykka/compat.py", line 12, in reraise
exec('raise tp, value, tb')
File "/usr/local/lib/python2.7/site-packages/pykka/actor.py", line 201, in _actor_loop
response = self._handle_receive(message)
File "/usr/local/lib/python2.7/site-packages/pykka/actor.py", line 295, in _handle_receive
return callee(*message['args'], **message['kwargs'])
File "/usr/local/lib/python2.7/site-packages/mopidy/core/playback.py", line 305, in play
self._play(tl_track=tl_track, tlid=tlid, on_error_step=1)
File "/usr/local/lib/python2.7/site-packages/mopidy/core/playback.py", line 348, in _play
backend.playback.change_track(tl_track.track).get() and
File "/usr/local/lib/python2.7/site-packages/pykka/threading.py", line 52, in get
compat.reraise(*self._data['exc_info'])
File "/usr/local/lib/python2.7/site-packages/pykka/compat.py", line 12, in reraise
exec('raise tp, value, tb')
File "/usr/local/lib/python2.7/site-packages/pykka/actor.py", line 201, in _actor_loop
response = self._handle_receive(message)
File "/usr/local/lib/python2.7/site-packages/pykka/actor.py", line 295, in _handle_receive
return callee(*message['args'], **message['kwargs'])
File "/usr/local/lib/python2.7/site-packages/mopidy/backend.py", line 245, in change_track
uri = self.translate_uri(track.uri)
File "/usr/local/lib/python2.7/site-packages/mopidy/stream/actor.py", line 90, in translate_uri
tracks = list(playlists.parse(content))
File "/usr/local/lib/python2.7/site-packages/mopidy/internal/playlists.py", line 28, in parse
return parse_urilist(data)  # Fallback
File "/usr/local/lib/python2.7/site-packages/mopidy/internal/playlists.py", line 125, in parse_urilist
if not line.strip() or line.startswith('#'):
UnicodeDecodeError: 'ascii' codec can't decode byte 0xdf in position 154: ordinal not in range(128)
DEBUG    2015-08-22 22:19:38,326 [855:Audio-2] mopidy.audio.actor
Position query failed

# Fixed code
def parse_urilist(data):
    result = []
    for line in data.splitlines():
        if not line.strip() or line.startswith(b"#"):
            continue
        try:
            validation.check_uri(line)
        except ValueError:
            return []
        result.append(line)
    return result