ParamSpec(bound=None) incorrectly sets __bound__ to NoneType
Offen
Dieses Issue hat noch niemand übernommen.
stdlib
topic-typing
type-bug
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit der ParamSpec-Implementierung und führe die bereitgestellte Reproduktion auf CPython main aus. Überprüfe, dass ein nicht gebundener ParamSpec und einer, der mit bound=None erstellt wurde, bound als None offenlegen, während ein explizit gebundener ParamSpec seine Bindung beibehält; der Issue verweist auf PR gh-142751, sieh dir diese Arbeit daher zuerst an.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- backend
- Issue-Typ
- Bug
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 20/100