jdlorimer / incremental-reading

Anki add-on providing incremental reading features
https://ankiweb.net/shared/info/935264945
ISC License
217 stars 38 forks source link

Python 3.9 compatibilty issue : AttributeError: module 'base64' has no attribute 'decodestring' #120

Closed sosie-js closed 2 years ago

sosie-js commented 3 years ago

Describe the bug On launch I got the error

addons21/935264945/lib/feedparser.py", line 93, in <module>
    _base64decode = getattr(base64, 'decodebytes', base64.decodestring)
AttributeError: module 'base64' has no attribute 'decodestring'

How To Solve Edit feedparser.py and complete the script from

try:
    import base64, binascii
except ImportError:
    base64 = binascii = None
else:
    # Python 3.1 deprecates decodestring in favor of decodebytes
    _base64decode = getattr(base64, 'decodebytes', base64.decodestring)

to

try:
    import base64, binascii
except ImportError:
    base64 = binascii = None
else:
    import sys
    if not sys.version_info.major == 3 and sys.version_info.minor >= 9:
        # Python 3.1 deprecates decodestring in favor of decodebytes
        _base64decode = getattr(base64, 'decodebytes', base64.decodestring)
    else:
        _base64decode = getattr(base64, 'decodebytes', base64.decodebytes)

have a nice week..