python / python/peps

PEP 554: Issues with data passing and pickle

未关闭
#3,309 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
reStructuredText
星标
5k
派生
1.8k
平均合并
2 天 4 小时
30 天内合并 PR
25

描述

I believe the example program given in PEP 554: https://peps.python.org/pep-0554/#passing-objects-via-pickle has some issues. It's based on a zero value (b'\x00') being a data terminator, but my attempts to recreate this (using threads instead of interpreters) showed that pickle will insert zero values in the middle of the data stream:

Python 3.10.4 (main, May  7 2022, 16:23:10) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pickle
>>> pickle.dumps("PEP 554")
b'\x80\x04\x95\x0b\x00\x00\x00\x00\x00\x00\x00\x8c\x07PEP 554\x94.'

I think the goal here is to simply demonstrate passing pickled objects through the pipe. To that end, it might make a better example to change the reading portion to read a fixed, relatively large, buffer at once and then decode that. Something like:

    data = os.read(reader, 1024)
    obj = pickle.loads(data)
    do_something(obj)

This is clearly not a general purpose solution, but I think for an example like this, not solving all of the corner cases is OK.

Thanks for all of the tremendous work already put into this! This will be very cool!

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

打开 PEP 554 的“Passing Objects via Pickle”部分,检查示例中的管道读取和终止逻辑。根据所示的 pickle 输出验证该示例,然后更新示例,使其文档所述的行为与预期演示一致,并确认修订后的代码片段可以加载 pickle 对象。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
documentation
Issue 类型
文档
难度
2/5
预计耗时
1-3 小时
活跃度
停滞
描述清晰度
描述清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。