Pickle `FLOAT` opcode inconsistency with whitespace
未關閉
還沒有人認領這個 Issue。
extension-modules
type-feature
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
Bug report
Bug description:
A lot of Python code tolerates leading and trailing whitespace in string-to-number conversions. However, in the FLOAT opcode of pickle, the Python implementation can tolerate leading/trailing whitespace, while the C implementation throws an error and can't convert it. Note that the INT opcode can gracefully handle leading/trailing whitespace (in both Python and C).
Payloads:
payload: b'F 5\n.'
pickle: 5.0
_pickle.c: FAILURE could not convert string to float: ' 5
'
pickletools:
0: F FLOAT 5.0
4: . STOP
highest protocol among opcodes = 0
payload: b'F5 \n.'
pickle: 5.0
_pickle.c: FAILURE could not convert string to float
pickletools:
0: F FLOAT 5.0
4: . STOP
highest protocol among opcodes = 0
payload: b'I 5 \n.'
pickle: 5
_pickle.c: 5
pickletools:
0: I INT 5
5: . STOP
highest protocol among opcodes = 0
CPython versions tested on:
3.13
Operating systems tested on:
Linux
Linked PRs
- gh-135619
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
首先定位 pickle 的 Python 和 C 實作中的 FLOAT opcode,並比較它們對所提供 payload 的處理方式。在 Python 3.13 上執行範例,然後驗證兩個實作對前導和尾端空白的處理是否一致。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- backend
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 35/100