Tuesday, October 26, 2021

[SOLVED] decodestrings is not an attribute of base64 error in python 3.9.1

Issue

After upgrading from python 3.8.0 to python 3.9.1, the tremc front-end of transmission bitTorrent client is throwing decodestrings is not an attribute of base64 error whenever i click on a torrent entry to check the details.

My system specs: OS: Arch linux kernel: 5.6.11-clear-linux


Solution

So i went to the site-packages directory and with ripgrep tried searching for the decodestring string.

 rg decodestring
    
    paramiko/py3compat.py
    39:    decodebytes = base64.decodestring 

Upon examining the py3compat.py file,i found this block:

PY2 = sys.version_info[0] < 3

if PY2:
    string_types = basestring  # NOQA
    text_type = unicode  # NOQA
    bytes_types = str
    bytes = str
    integer_types = (int, long)  # NOQA
    long = long  # NOQA
    input = raw_input  # NOQA
    decodebytes = base64.decodestring
    encodebytes = base64.encodestring

So decodebytes have replaced(aliased) decodestring attribute of base64 for python version >= 3 This must be a new addendum because tremc was working fine in uptil version 3.8.*.

Opened tremc script, found the erring line (line 441), just replaced the attribute decodestring with decodebytes.A quick fix till the next update.

PS: Checked the github repository, and there's a pull request for it in waiting. If you don't want to wait for the next release and also don't want to hack the way i did, you can get it freshly build from the repository, though that would be not much of a difference than my method



Answered By - Just Khaithang