-
Notifications
You must be signed in to change notification settings - Fork 109
Open
Description
I'd expect Search to take Unicode objects in Python 2.7:
# -*- coding: utf-8 -*-
from yelp.client import Client
from yelp.oauth1_authenticator import Oauth1Authenticator
auth = Oauth1Authenticator(...)
client = Client(auth)
response = client.search('San Francisco', term=u'aü')
It fails:
Traceback (most recent call last):
File "foo.py", line 19, in <module>
response = client.search('San Francisco', term=u'aü')
File "/nail/home/kmitton/pg/other/yelp-python/yelp/endpoint/search.py", line 44, in search
self.client._make_request(SEARCH_PATH, url_params)
File "/nail/home/kmitton/pg/other/yelp-python/yelp/client.py", line 47, in _make_request
signed_url = self.authenticator.sign_request(url, url_params)
File "/nail/home/kmitton/pg/other/yelp-python/yelp/oauth1_authenticator.py", line 36, in sign_request
return oauth_request.to_url()
File "/nail/home/kmitton/pg/kmitton-bash/virtualenv_run/lib/python2.7/site-packages/oauth2/__init__.py", line 363, in to_url
urllib.urlencode(query, True), fragment)
File "/usr/lib64/python2.7/urllib.py", line 1354, in urlencode
l.append(k + '=' + quote_plus(str(elt)))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 1: ordinal not in range(128)
Workaround: Manually encode as UTF-8 bytestring:
response = client.search('San Francisco', term=u'aü'.encode('utf8'))
Feels like we should be able to handle Unicode.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels