-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Labels
Description
Hi,
In the example echobot.py, the string to be sent is converted to bytes with .encode('utf-8') but the json.dumps() function cannot handle this. I suspect this to be a python3 issue. Can I just remove the encode() ?
File "echobot.py", line 50, in <module>
main()
File "echobot.py", line 28, in main
echo(bot)
File "echobot.py", line 43, in echo
bot.sendMessage(chat_id=chat_id,text=message)
File "/usr/local/lib/python3.4/dist-packages/telegram/bot.py", line 126, in decorator
result = func(self, *args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/telegram/bot.py", line 158, in decorator
result = request.post(url, data)
File "/usr/local/lib/python3.4/dist-packages/telegram/utils/request.py", line 88, in post
data = json.dumps(data)
File "/usr/lib/python3.4/json/__init__.py", line 230, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python3.4/json/encoder.py", line 192, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.4/json/encoder.py", line 250, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python3.4/json/encoder.py", line 173, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: b'test' is not JSON serializable
Nice work btw!