tarfile.TarFile.errors is initialized for some reason as None even though it really only accepts str
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
Bug report
Bug description:
See the exact line here: https://github.com/python/cpython/blob/ee57221872ad009df648e22d2f113f907607ec16/Lib/tarfile.py#L1687
After that the errors is used only as string in encode/decode. And is initialized in the dunder init with default errors="surrogateescape".
So perhaps it would be a good idea to use errors="" in #L1687 ? or directly with the default errors="surrogateescape" ?
This was discovered as part of the typeshed, where tarfile.TarFile.errors was added into the allowed list since mypy complained: https://github.com/python/typeshed/blob/2ccc53bb6716463680fcf1d204642c46299b7f88/stdlib/%40tests/stubtest_allowlists/common.txt#L46C1-L46C16
I will add a PR here and to the typeshed if this gets approved.
CPython versions tested on:
3.13
Operating systems tested on:
Windows
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 Lib/tarfile.py 第 1687 行開始,檢查 TarFile initializer 以及之後在 encode/decode 中對 errors 的使用。檢查 typeshed 中對應的 allowlist 項目,然後確認 runtime initialization 與 typing 一致;如有需要,更新相應的 CPython 和 typeshed 變更。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- backend
- Issue 類型
- 缺陷
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 38/100