typing._allow_reckless_class_checks doesn't work when _abc doesn't exist.
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Bug report
Bug description:
When typing._caller's sys._getframe fallback is triggered without _abc module, _typing._allow_reckless_class_checks fails to check _py_abc while running abc.ABCMeta.__instancecheck__.
Without _abc module, _typing._allow_reckless_class_checksfails to check _py_abc
Related code in typing.py:
https://github.com/python/cpython/blob/v3.14.0b3/Lib/typing.py#L1846-L1863
This is technically a bug of typing.py, but really hard to be triggered on CPython.
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Solution suggestion
Patch typing._allow_reckless_class_checks to also check _py_abc
This is the most conservative approach. Compatible with all of previous scenarios and additionally fixing the bug.
Patch typing._caller to remove sys._getframe or raise warning when fallback
If the the typing requires to work with sys._getframemodulename, then let the users to know it has a caveat.
Linked PRs
- gh-136115
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
Lies Lib/typing.py in den Zeilen 1846-1863 und vergleiche die vorgeschlagene Änderung mit dem verlinkten PR gh-136115. Die Aufgabe ist erledigt, wenn _allow_reckless_class_checks auch _py_abc behandelt, sobald _abc nicht verfügbar ist, und das Verhalten im CPython main branch verifiziert wurde.
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
- 25/100