Good morning. There is a telegram bot that has been operating for more than 3 months, but from time to time (2-5 days), it crashes:

Exception in thread WorkerThread2: Traceback (most recent call last): File "site-packages\telebot\util.py", line 54, in run File "main.py", line 200, in handle_text File "main.py", line 23, in log File "c:\users\root\appdata\local\programs\python\python35\lib\encodings\cp866.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_map)[0] UnicodeEncodeError: 'charmap' codec can't encode character '\u0456' in position 20: character maps to <undefined> During handling of the above exception, another exception occurred: Traceback (most recent call last): File "threading.py", line 914, in _bootstrap_inner File "site-packages\telebot\util.py", line 65, in run File "site-packages\telebot\util.py", line 98, in on_exception File "site-packages\telebot\util.py", line 206, in <lambda> File "site-packages\telebot\util.py", line 193, in or_set File "site-packages\telebot\util.py", line 206, in <lambda> File "site-packages\telebot\util.py", line 193, in or_set ................ 

Why this happens, I do not understand, they write on the Internet that the problem is with the encodings, but I'm fine.

The bot has a log and I see that the bot is written and that the bot writes in response. When an error occurs, there is nothing in the logs, nobody writes anything to it, it just takes and gets into an infinite loop.

Tell me what the problem is or direct it on the right path. thank

  • Because the console console (by default) does not support unicode; see this answer . It is the log that falls, so there is nothing in the logs :) - andmalmal
  • @andreymal hmm, I wonder) You're right, this is a problem of the Windows console, in the pycharme itself I don’t see this problem, and when I compile the bot through (Pyinstaller) into one exe file, the problem appears - Vladimir V.
  • @ ВладимирВ .: Does the error disappear if you update the Python? - jfs

0