python / python/cpython

tarfile.TarFile.errors is initialized for some reason as None even though it really only accepts str

オープン
#127,424 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

stdlib type-bug
主要言語
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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. 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

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。