【发布时间】:2021-03-19 02:20:44
【问题描述】:
从python 3.8.0升级到python 3.9.1后,每次点击torrent入口查看详细信息时,传输bitTorrent客户端的tremc前端都会抛出decodestrings is not an attribute of base64错误。
我的系统规格: 操作系统:Arch linux 内核:5.6.11-clear-linux
【问题讨论】:
标签: linux base64 python-3.9
从python 3.8.0升级到python 3.9.1后,每次点击torrent入口查看详细信息时,传输bitTorrent客户端的tremc前端都会抛出decodestrings is not an attribute of base64错误。
我的系统规格: 操作系统:Arch linux 内核:5.6.11-clear-linux
【问题讨论】:
标签: linux base64 python-3.9
所以我去了 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()
【讨论】: