Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled exception when search term contains UTF-8 #57

Open
fatg3erman opened this issue Aug 10, 2015 · 1 comment
Open

Unhandled exception when search term contains UTF-8 #57

fatg3erman opened this issue Aug 10, 2015 · 1 comment
Labels
C-bug Category: This is a bug

Comments

@fatg3erman
Copy link

OSX, running mopidy from git with mopidy-soundcloud installed from homebrew

When searching (via the MPD interface):

search artist "Air" album "Premiers Symptômes"

I get an unhandled exception:

INFO     Searching SoundCloud for 'Premieres Symptômes Air'
ERROR    Unhandled exception in MpdSession (urn:uuid:9f04da0f-fc43-42f1-948c-3099bcfcf0cf):
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pykka/actor.py", line 200, in _actor_loop
    response = self._handle_receive(message)
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pykka/actor.py", line 303, in _handle_receive
    return self.on_receive(message)
  File "/Users/bob/mopidy-dev/mopidy/mopidy/internal/network.py", line 370, in on_receive
    self.on_line_received(line)
  File "/Users/bob/mopidy-dev/mopidy/mopidy/mpd/session.py", line 34, in on_line_received
    response = self.dispatcher.handle_request(line)
  File "/Users/bob/mopidy-dev/mopidy/mopidy/mpd/dispatcher.py", line 47, in handle_request
    return self._call_next_filter(request, response, filter_chain)
  File "/Users/bob/mopidy-dev/mopidy/mopidy/mpd/dispatcher.py", line 68, in _call_next_filter
    return next_filter(request, response, filter_chain)
  File "/Users/bob/mopidy-dev/mopidy/mopidy/mpd/dispatcher.py", line 76, in     _catch_mpd_ack_errors_filter
    return self._call_next_filter(request, response, filter_chain)
  File "/Users/bob/mopidy-dev/mopidy/mopidy/mpd/dispatcher.py", line 68, in _call_next_filter
    return next_filter(request, response, filter_chain)
  File "/Users/bob/mopidy-dev/mopidy/mopidy/mpd/dispatcher.py", line 89, in _authenticate_filter
    return self._call_next_filter(request, response, filter_chain)
  File "/Users/bob/mopidy-dev/mopidy/mopidy/mpd/dispatcher.py", line 68, in _call_next_filter
    return next_filter(request, response, filter_chain)
  File "/Users/bob/mopidy-dev/mopidy/mopidy/mpd/dispatcher.py", line 105, in _command_list_filter
    response = self._call_next_filter(request, response, filter_chain)
  File "/Users/bob/mopidy-dev/mopidy/mopidy/mpd/dispatcher.py", line 68, in _call_next_filter
    return next_filter(request, response, filter_chain)
  File "/Users/bob/mopidy-dev/mopidy/mopidy/mpd/dispatcher.py", line 134, in _idle_filter
    response = self._call_next_filter(request, response, filter_chain)
  File "/Users/bob/mopidy-dev/mopidy/mopidy/mpd/dispatcher.py", line 68, in _call_next_filter
    return next_filter(request, response, filter_chain)
  File "/Users/bob/mopidy-dev/mopidy/mopidy/mpd/dispatcher.py", line 147, in _add_ok_filter
    response = self._call_next_filter(request, response, filter_chain)
  File "/Users/bob/mopidy-dev/mopidy/mopidy/mpd/dispatcher.py", line 68, in _call_next_filter
    return next_filter(request, response, filter_chain)
  File "/Users/bob/mopidy-dev/mopidy/mopidy/mpd/dispatcher.py", line 159, in _call_handler_filter
    response = self._format_response(self._call_handler(request))
  File "/Users/bob/mopidy-dev/mopidy/mopidy/mpd/dispatcher.py", line 174, in _call_handler
    return protocol.commands.call(tokens, context=self.context)
  File "/Users/bob/mopidy-dev/mopidy/mopidy/mpd/protocol/__init__.py", line 180, in call
    return self.handlers[tokens[0]](context, *tokens[1:])
  File "/Users/bob/mopidy-dev/mopidy/mopidy/mpd/protocol/__init__.py", line 142, in validate
    return func(*args, **kwargs)
  File "/Users/bob/mopidy-dev/mopidy/mopidy/mpd/protocol/music_db.py", line 443, in search
    results = context.core.library.search(query).get()
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/pykka/future.py", line 299, in get
    exec('raise exc_info[0], exc_info[1], exc_info[2]')
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pykka/actor.py", line 200, in _actor_loop
    response = self._handle_receive(message)
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pykka/actor.py", line 294, in _handle_receive
    return callee(*message['args'], **message['kwargs'])
  File "/Users/bob/mopidy-dev/mopidy/mopidy/core/library.py", line 342, in search
    result = future.get()
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pykka/future.py", line 299, in get
    exec('raise exc_info[0], exc_info[1], exc_info[2]')
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pykka/actor.py", line 200, in _actor_loop
    response = self._handle_receive(message)
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pykka/actor.py", line 294, in _handle_receive
    return callee(*message['args'], **message['kwargs'])
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mopidy_soundcloud/library.py", line 196, in search
    tracks=self.backend.remote.search(search_query)
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mopidy_soundcloud/soundcloud.py", line 212, in search
    quote_plus(query), self.explore_songs))
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 1308, in quote_plus
    s = quote(s, safe + ' ')
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 1303, in quote
    return ''.join(map(quoter, s))
KeyError: u'\xf4'
@jodal
Copy link
Member

jodal commented Aug 10, 2015

The query string probably needs to be encoded to UTF-8 bytes before being passed to urllib.quote_plus(). urllib cannot guess what encoding the chars in a Unicode string should have, so we have to be explicit about it.

@jodal jodal added the C-bug Category: This is a bug label Aug 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug
Projects
None yet
Development

No branches or pull requests

2 participants