jaraco / irc

Full-featured Python IRC library for Python.
MIT License
392 stars 86 forks source link

IRClib crashes on certain network inputs #43

Closed jaraco closed 8 years ago

jaraco commented 8 years ago

Intermittently, on certain (unknown) kinds of network input, IRClib crashes with backtrace similar to the following:

  File "./countbot.py", line 280, in <module>
    main()
  File "./countbot.py", line 277, in main
    bot.start()
  File "/usr/lib64/python3.4/site-packages/irc-8.9.1-py3.4.egg/irc/bot.py", line 266, in start
  File "/usr/lib64/python3.4/site-packages/irc-8.9.1-py3.4.egg/irc/client.py", line 1263, in start
  File "/usr/lib64/python3.4/site-packages/irc-8.9.1-py3.4.egg/irc/client.py", line 280, in process_forever
  File "/usr/lib64/python3.4/site-packages/irc-8.9.1-py3.4.egg/irc/client.py", line 261, in process_once
  File "/usr/lib64/python3.4/site-packages/irc-8.9.1-py3.4.egg/irc/client.py", line 218, in process_data
  File "/usr/lib64/python3.4/site-packages/irc-8.9.1-py3.4.egg/irc/client.py", line 575, in process_data
  File "/usr/lib64/python3.4/site-packages/irc-8.9.1-py3.4.egg/irc/buffer.py", line 94, in lines
  File "/usr/lib64/python3.4/site-packages/irc-8.9.1-py3.4.egg/irc/buffer.py", line 92, in lines
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x81 in position 138: invalid start byte

Several different IRC bots in the same channel, running same IRClib, respond differently; one crashes as above, one apparently loses server connection but automatically reconnects, one appears to quit normally with no exception or backtrace. Unknown how exactly this is happening.


jaraco commented 8 years ago

The IRC lib is opinionated about the expected character encoding, requiring UTF-8 from all clients (which is not a requirement in the specification). The IRC library provides several techniques for overriding the encoding, which are detailed in the Decoding Input section of the homepage for the library.

The reason different clients have different behavior probably has to do with the way that each of those clients handle errors, as the IRC library itself is consistent in its error handling.


Original comment by: Jason R. Coombs