Python pickle `load_reduce` function doesn't check if `args` is a tuple
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
Bug description:
When load_reduce() is called in Python pickle, the args variable is pulled off the stack and passed into the functions using the * operator. This syntax is type-permissive, meaning the type can be any iterable that will return the needed arguments.
However, in C _pickle, argtup is pulled off the stack and passed into PyObject_CallObject(), which checks if the args parameter is specifically a PyTuple().
This means that any non-tuple iterator being used as the arguments passed into the function will cause C _pickle to throw an error, but Python pickle deserialization to unfold just fine.
payload: b'cbuiltins\nprint\n}R.'
pickle:
None
_pickle.c: FAILURE argument list must be a tuple
pickletools:
0: c GLOBAL 'builtins print'
16: } EMPTY_DICT
17: R REDUCE
18: . STOP
highest protocol among opcodes = 1
I think the easiest way to remedy the discrepancy is to explicitly type check the args parameter in pickle.py's load_reduce() function.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
- gh-144419
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Lib/pickle.py の load_reduce() から始め、その引数処理を Modules/_pickle.c および Objects/call.c で参照されている PyObject_CallObject() の動作と比較してください。リンクされている PR gh-144419 と既存の pickle テストを確認してください。完了の条件は、Python pickle と _pickle が報告された非タプル引数のケースを一貫して処理することです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 25/100