Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Search can't handle Unicode terms

Open
#46 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
api

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Yelp/yelp-python

All issues in Yelp/yelp-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.