warnings: adding new filter resets prior existing "once" filters
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
Bug description:
If a filter is defined with action="once", the occurrence tracking is reset each time a new filter is defined. This can override the ability to effectively use action="once" if the filter manipulation occurs in a library which the user cannot control (e.g. matplotlib).
For example, the following code will only output a warning once (i.e. works as intended):
import warnings
warnings.filterwarnings("once", "test warning", UserWarning)
warnings.warn("test warning", UserWarning)
warnings.warn("test warning", UserWarning)
However, simply inserting an unrelated filter prior to the second warning will cause both to be output:
warnings.filterwarnings("once", "test warning", UserWarning)
warnings.warn("test warning", UserWarning)
warnings.filterwarnings("ignore", "something unrelated")
warnings.warn("test warning", UserWarning)
CPython versions tested on:
3.14
Operating systems tested on:
Linux
Linked PRs
- gh-153697
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Issue にある warnings.filterwarnings と warnings.warn の再現コードから始め、その後 CPython 内の warnings の実装とテストを特定します。既存の action="once" フィルターについて、無関係なフィルターを追加しても発生回数の追跡がリセットされなくなれば完了です。gh-153697 はすでにこの issue にリンクされています。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 25/100