gfcapalbo / python-twitter

Automatically exported from code.google.com/p/python-twitter
Apache License 2.0
0 stars 0 forks source link

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

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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 biswasp...@gmail.com on 6 Dec 2012 at 5:12