cvium / irc_bot

Simple library for creating an IRC bot
MIT License
9 stars 7 forks source link

Python 3.9 compatibility #5

Closed pogman-code closed 3 years ago

pogman-code commented 3 years ago

Hi, After the 3.9 update I have the following error:

"/home/<USER>/.local/lib/python3.9/site-packages/irc_bot/utils.py", line 48, in decode_html
Dec 07 19:32:19 <USER> flexget[118472]:     return h.unescape(data)
Dec 07 19:32:19 <USER> flexget[118472]:            |          -> 'PING :XXXXXXX'
Dec 07 19:32:19 <USER> flexget[118472]:            -> <html.parser.HTMLParser object at 0x7f6f66741280>
Dec 07 19:32:19 <USER> flexget[118472]: AttributeError: 'HTMLParser' object has no attribute 'unescape'

And according to https://docs.python.org/3/whatsnew/3.9.html

The unescape() method in the html.parser.HTMLParser class has been removed (it was deprecated since Python 3.4). 
html.unescape() should be used for converting character references to the corresponding unicode characters.

Let me know if I can be of any help resolving this :)

cvium commented 3 years ago

It doesn't look like python-future has implemented html.unescape, so to fix it I guess you would have to do some try except stuff or check for python version.

It's not something I am going to fix, but I do accept pull requests.

pogman-code commented 3 years ago

Yes, I realized my mistake later as I didn't thought of Python 2 backward compatibility.

As far as I understand it irc_bot use six to ensure it so I guess it's up to six to fix this issue :) It as been brought there: https://github.com/benjaminp/six/issues/340

Sadly I am not very familiar with six so I don't think I'll be able to provide a fix for them to merge, hopefully someone will :D

cvium commented 3 years ago

I use both future and six. Neither have support for html.unescape yet.

cvium commented 3 years ago

Should be fixed by the newest release