Search can't handle Unicode terms
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
Start by reproducing the Unicode search example and trace the request through yelp/endpoint/search.py, yelp/client.py, and yelp/oauth1_authenticator.py to the signing step shown in the traceback. Done means a Unicode term such as u'aü' works without callers manually encoding it as UTF-8.
Written by the indexing model from the issue text.
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.
- Dominant language
- Python
- Stars
- 183
- Forks
- 109
- PR merge metrics
- No merged PRs in 30d
Getting set up
We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Yelp/yelp-python
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
Yelp/yelp-python#79 · 3 comments · 1 reaction ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Yelp/yelp-python#76 · 1 reaction ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Yelp/yelp-python#75 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Yelp/yelp-python#74 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Yelp/yelp-python#73 ·
All issues in Yelp/yelp-python
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
PedestrianDynamics/pyFDS-Evac#199 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
521xueweihan/HelloGitHub#3790 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
sandialabs/atlas-ui-3#978 ·
Maintainers usually reply within 1 day
-
area: tests perceived difficulty: 2
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Nitjsefnie-Harness-Commons/daedalus#1255 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
EleutherAI/lm-evaluation-harness#4256 ·
Maintainers usually reply within 1 day