Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Issue with pickling an unpickled object

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

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
32/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
python
领域
tooling

调研方向

首先,使用提供的类方法和字节码详细信息,在 Python 3.9.6 和 cloudpickle 2.0.0 下重现报告的往返过程。跟踪第二次 cloudpickle 操作经过字节码处理并到达 dis.py 的过程;当对象能够在不出现 IndexError 的情况下再次进行 pickle,并且回归问题由可复现的测试覆盖时,即可认为该问题已完成。

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

描述

lacking reproducer

Python 3.9.6 | cloudpickle 2.0.0
While using cloudpickle to pack some classes, I encountered the following error:
\lib\dis.py", line 347, in _get_instructions_bytes argval = cmp_op[arg] IndexError: tuple index out of range
arg = 6
op = 107

Here is the segment of code (a class method) it was processing when the error occurred:

def startTimer(self,name):  
    if name in self.timers and not self.timers[name]['start'] is None:
        if self.timers[name]['stop'] is None:
            print(f"Timer ({name}) has already been started..")
            return 
        else:
            print(f"Timer ({name}) being restarted from last stop ({self.timers[name]['stop']})")
    self.timers[name]={"start":time(),"stop":None}

Here is the bytecode:

b't\x00d\x01d\x02\x8d\x01|\x00_\x01d\x03g\x01|\x00_\x02d\x04|\x00_\x03g\x00|\x00_\x04d\x00|\x00_\x05|\x01|\x00_\x06|\x00\xa0\x07\xa1\x00\x01\x00t\x08|\x00j\x01\x83\x01\x01\x00d\x00S\x00'

Here is the unpacked code:

[(0, 116, 0), (2, 100, 1), (4, 100, 2), (6, 141, 1), (8, 124, 0), (10, 95, 1), (12, 100, 3), (14, 103, 1), (16, 124, 0), (18, 95, 2), (20, 100, 4), (22, 124, 0), (24, 95, 3), (26, 103, 0), (28, 124, 0), (30, 95, 4), (32, 100, 0), (34, 124, 0), (36, 95, 5), (38, 124, 1), (40, 124, 0), (42, 95, 6), (44, 124, 0), (46, 160, 7), (48, 161, 0), (50, 1, None), (52, 116, 8), (54, 124, 0), (56, 106, 1), (58, 131, 1), (60, 1, None), (62, 100, 0), (64, 83, None)]

This is happening when I try to re-cloudpickle an object that was already pickled and loaded with cloudpickle. The original pickling goes through fine, I am able to unpack it without issues, but when I try to re-pickle the unpacked object again I get the above error.

主要语言
Python
星标
1.9k
派生
197
平均合并
1 天 10 小时
30 天内合并 PR
1

贡献指南

这个仓库没有索引到贡献指南

从这里开始

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

cloudpipe/cloudpickle 的其他 Issue

查看 cloudpipe/cloudpickle 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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