python-chatbot icon indicating copy to clipboard operation
python-chatbot copied to clipboard

Twitter feature chokes on tweets with unicode characters

Open harrislapiroff opened this issue 12 years ago • 0 comments

Traceback is, e.g.,

Traceback (most recent call last):
  File "/home/hlapiroff/.virtualenvs/granola/local/lib/python2.7/site-packages/twisted/internet/tcp.py", line 209, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "/home/hlapiroff/.virtualenvs/granola/local/lib/python2.7/site-packages/twisted/words/protocols/irc.py", line 2413, in dataReceived
    basic.LineReceiver.dataReceived(self, data.replace('\r', ''))
  File "/home/hlapiroff/.virtualenvs/granola/local/lib/python2.7/site-packages/twisted/protocols/basic.py", line 564, in dataReceived
    why = self.lineReceived(line)
  File "/home/hlapiroff/.virtualenvs/granola/local/lib/python2.7/site-packages/twisted/words/protocols/irc.py", line 2421, in lineReceived
    self.handleCommand(command, prefix, params)
--- <exception caught here> ---
  File "/home/hlapiroff/.virtualenvs/granola/local/lib/python2.7/site-packages/twisted/words/protocols/irc.py", line 2465, in handleCommand
    method(prefix, params)
  File "/home/hlapiroff/.virtualenvs/granola/local/lib/python2.7/site-packages/twisted/words/protocols/irc.py", line 1937, in irc_PRIVMSG
    self.privmsg(user, channel, message)
  File "/home/hlapiroff/.virtualenvs/granola/src/chatbot/chatbot/client.py", line 29, in privmsg
    response = feature.handle_query(query)
  File "/home/hlapiroff/.virtualenvs/granola/src/chatbot/chatbot/contrib/twitter.py", line 28, in handle_query
    return ChatResponse(str(response_content))
exceptions.UnicodeEncodeError: 'ascii' codec can't encode character u'\u201c' in position 58: ordinal not in range(128)

Fix should be here: https://github.com/harrislapiroff/python-chatbot/blob/master/chatbot/contrib/twitter.py#L27

harrislapiroff avatar Feb 08 '13 19:02 harrislapiroff