gkrizek / ghi

GitHub IRC Notification Service
MIT License
26 stars 8 forks source link

python3.9 - module 'base64' has no attribute 'encodestring' #12

Closed thezoggy closed 2 years ago

thezoggy commented 3 years ago
2021-06-29 18:25:41 [ghi] IRC - Connecting to irc.libera.chat:6667 with nick nickname and channels: #channel
2021-06-29 18:25:42 [ghi] IRC - There was a problem sending messages to IRC
2021-06-29 18:25:42 [ghi] IRC - module 'base64' has no attribute 'encodestring'
2021-06-29 18:25:42 [ghi] Something went wrong while trying to notify IRC.

offending line: https://github.com/gkrizek/ghi/blob/master/ghi/irc.py#L87

can see that this fails in python 3.9.x

$ python3
Python 3.9.4 (default, Apr  9 2021, 01:15:05)
>>> blah = base64.encodestring("whatever".encode("UTF-8"))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'base64' has no attribute 'encodestring'

https://docs.python.org/3.9/whatsnew/3.9.html

base64.encodestring() and base64.decodestring(), aliases deprecated since Python 3.1, have been removed: use base64.encodebytes() and base64.decodebytes() instead. (Contributed by Victor Stinner in bpo-39351.)

changing encodestring to encodebytes resoles error and bot works again:

IRC - Connection Successful