ParamSpec(bound=None) incorrectly sets __bound__ to NoneType
オープン
まだ誰も着手していません。
stdlib
topic-typing
type-bug
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
Bug description:
When creating a ParamSpec with bound=None, the runtime bound attribute is set to <class 'NoneType'> instead of None.
How to reproduce
from typing import ParamSpec, Callable
P1 = ParamSpec("P")
P2 = ParamSpec("P", bound=None)
P3 = ParamSpec("P", bound=Callable[[int, str], float])
def check_bound(label, p, expected):
got = p.__bound__
ok = (got is expected)
exp_s = repr(expected)
got_s = repr(got)
print(f"{label}.__bound__ should be {exp_s}, got {got_s} -> {'OK' if ok else 'FAIL'}")
check_bound("P1", P1, None)
check_bound("P2", P2, None)
check_bound("P3", P3, Callable[[int, str], float])
Current behavior
d:\MyCode\cpython\PCbuild\amd64>python_d.exe py_bound.py
P1.__bound__ should be None, got <class 'NoneType'> -> FAIL
P2.__bound__ should be None, got <class 'NoneType'> -> FAIL
P3.__bound__ should be typing.Callable[[int, str], float], got typing.Callable[[int, str], float] -> OK
CPython versions tested on:
CPython main branch
Operating systems tested on:
Windows
Linked PRs
- gh-142751
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
ParamSpec の実装から始め、提供された再現コードを CPython main で実行します。未束縛の ParamSpec と bound=None で作成された ParamSpec が bound として None を公開する一方、明示的に bound が指定された ParamSpec はその bound を保持することを確認します。issue から PR gh-142751 にリンクされているため、まずその作業を確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 20/100