_pickle.UnpicklingError: Memo value not found at index 1
オープン
まだ誰も着手していません。
3.12
3.13
3.14
docs
stdlib
type-bug
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
Bug description:
When pickling a container object. The pickler class will store child-objects to its self.memo even if the container could not be fully pickled (and not written to the output).
This can cause references to memo objects that are not in the output stream.
import sys
import pickle
import io
buf = io.BytesIO()
pickler = pickle.Pickler(buf)
i_will_be_memorized = 'qqqqqqqqqqqq'
i_cant_be_pickled = sys
try:
pickler.dump([i_will_be_memorized, i_cant_be_pickled])
except TypeError:
# i_will_be_memorized is now in pickler memory despite the exception
pass
# this dump will use the memo
pickler.dump(i_will_be_memorized)
data = buf.getbuffer().tobytes()
# so this will fail with:
# _pickle.UnpicklingError: Memo value not found at index 1
pickle.loads(data)
CPython versions tested on:
3.12
Operating systems tested on:
Windows
Linked PRs
- gh-125762
- gh-130231
- gh-130232
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
issue にある Python pickle と io.BytesIO のスニペットで失敗を再現し、その後、失敗したコンテナダンプに関連する pickle.Pickler の memo 処理を調査します。後続のダンプが出力ストリームに存在しない memo エントリを参照せず、示されたシーケンスに対する回帰テストのカバレッジがあることを完了条件とします。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 25/100