python / python/cpython

typing._allow_reckless_class_checks doesn't work when _abc doesn't exist.

Aperta
#136,047 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

topic-typing type-bug
Lingua principale
Python
Stelle
77.2k
Fork
35.9k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Leggi le righe 1846-1863 di Lib/typing.py e confronta la modifica proposta con la PR collegata gh-136115. Il lavoro è completato quando _allow_reckless_class_checks gestisce anche _py_abc quando _abc non è disponibile, con il comportamento verificato sul branch principale di CPython.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
backend
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.