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

"UnicodeEncodeError: 'ascii' codec can't encode characters" during GetSearch() for utf-8 encoded search terms #245

Open
GoogleCodeExporter opened this issue Aug 6, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. term = u'\u0915\u0932\u092E'
2. term.encode('utf-8')
3. search_results = api.GetSearch(term)

What is the expected output? What do you see instead?
I expect to get tweets containing the string 'term'. Instead, I get the 
following error:

    search_results = api.GetSearch(term)
  File "/usr/local/lib/python2.7/dist-packages/python_twitter-0.8.3-py2.7.egg/twitter.py", line 2421, in GetSearch
    json = self._FetchUrl(url, parameters=parameters)
  File "/usr/local/lib/python2.7/dist-packages/python_twitter-0.8.3-py2.7.egg/twitter.py", line 3854, in _FetchUrl
    url = req.to_url()
  File "/usr/lib/python2.7/dist-packages/oauth2/__init__.py", line 440, in to_url
    urllib.urlencode(query, True), fragment)
  File "/usr/lib/python2.7/urllib.py", line 1337, in urlencode
    l.append(k + '=' + quote_plus(str(elt)))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: 
ordinal not in range(128)

What version of the product are you using? On what operating system?
newest on ubuntu 12.04

Please provide any additional information below.
The following works:

    term = u'\u0915\u0932\u092E'
    api.PostUpdate(term)

Also, api.GetSearch("Thirsty") works.

Original issue reported on code.google.com by [email protected] on 6 Dec 2012 at 5:12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant