decodestrings is not an attribute of base64 error in python 3.9.1

decodestrings is not an attribute of base64 error in python 3.9.1

从 python 3.8.0 升级到 python 3.9.1 后,每当我点击 torrent 条目时,传输 bitTorrent 客户端的 tremc 前端就会抛出 decodestrings is not an attribute of base64 错误查看详情。

我的系统规格: OS:拱门linux 内核:5.6.11-清除-linux

所以我去了 site-packages 目录并使用 ripgrep 尝试搜索 decodestring 字符串。

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

检查 py3compat.py 文件后,我发现了这个块:

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

所以 decodebytes 已经为 python 版本替换了(别名)base64 的 decodestring 属性 >= 3 这一定是一个新的附录,因为 tremc 在 uptil 版本 3.8.*.

中运行良好

打开 tremc 脚本,发现错误行(第 441 行),只是将属性 decodestring 替换为 decodebytes。在下次更新前快速修复。

PS:检查了 github 存储库,有一个 pull 请求正在等待。 如果你不想等待下一个版本,也不想像我那样破解,你可以从存储库中重新构建它,尽管这与我的方法没有太大区别

base64.encodestring() 和 base64.decodestring(),自 Python 3.1 以来不推荐使用的别名,已被删除。

使用 base64.encodebytes() 和 base64.decodebytes()