typing._GenericAlias objects allow arbitrary dunder attribute creation
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Bug report
Bug description:
Objects like typing.List[int] allow arbitrary dunders to be set, and because of the cache, those attributes can leak to other objects created elsewhere in the program:
>>> x = List[int]
>>> x.__whatever__ = 42
>>> List[int].__whatever__
42
The cache behavior seems like it could lead to undesirable behavior. In 3.14 we somewhat accidentally fixed a similar bug with Union objects, and it turns out some people were relying on this: #132139. Let's think about whether we also want to remove this wart for other typing objects in 3.15.
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia riproducendo l'esempio typing.List[int] dell'issue e ispeziona l'implementazione e i test per gli alias generici; non viene indicato alcun file o test. Stabilisci innanzitutto il comportamento previsto per attributi dunder arbitrari e oggetti typing memorizzati nella cache, quindi aggiungi una copertura di regressione che dimostri che il comportamento è coerente senza che gli attributi trapelino tra gli oggetti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- developer-experience
- Tipo di issue
- Bug
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 35/100