frozendict cannot be pickled with protocols 0 and 1
未关闭
还没有人认领这个 Issue。
extension-modules
type-bug
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Bug report
frozendict cannot be pickled with protocols 0 and 1, while frozenset can:
>>> import pickle
>>> pickle.dumps(frozendict(a=1), 0)
Traceback (most recent call last):
...
TypeError: cannot pickle 'frozendict' object
>>> pickle.dumps(frozenset({1}), 0) # works
Protocols 2 through 5 already work. frozendict only defines __getnewargs__,
a protocol-2-and-later mechanism, while frozenset defines __reduce__, which
works at every protocol.
CPython versions tested on:
3.16 (main)
Operating systems tested on:
Linux, macOS
Linked PRs
- gh-155325
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先比较 frozendict 的 getnewargs 与 frozenset 的 reduce 的行为,以及协议 0 和 1 的 pickle.dumps 入口点。为两种协议添加回归覆盖,并确认 frozendict 可以被序列化和恢复,同时检查现有的关联 PR gh-155325,了解已经在进行的工作。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 35/100