python / python/cpython

Allow `FrameType` to be instantiated

Aperta
#149,844 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

interpreter-core type-feature
Lingua principale
Python
Stelle
77.2k
Fork
35.9k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

Feature or enhancement

Proposal:

For some reason, FrameType is not allowed to be instantiated. This creates problems when trying to (for example) control an exception traceback, which is common for debuggers, among other uses. This is also inconsistant with most other internal types that exposed to Python and in the types module.

The only reason I can think of is because PyFrame_New requires a PyThreadState object, which is not exposed to Python. However, there are several ways around this:

  • Run PyThreadState_GetUnchecked, raising RuntimeError (or another error) if NULL is returned
  • Expose frames' PyThreadState to the interpreter
  • Pass another frame as a parameter, and get its thread state

This should be relatively trivial to implement and I can't think of any downsides, backwards compatibility concerns, or maintenance overhead. I can probably write a PR if one of the solutions to the thread state parameter is decided.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

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

Inizia esaminando il percorso di istanziazione di FrameType e i punti di ingresso PyFrame_New e PyThreadState_GetUnchecked indicati nell’issue. Decidi come l’istanziazione debba ottenere o convalidare uno stato del thread, quindi verifica che FrameType possa essere creato da Python senza compromettere i casi d’uso indicati per traceback e debugger.

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

Valutazione

Stack tecnologico
python
Ambito
backend-api-design
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.