python / python/cpython

`concurrent.interpreters.Interpreter.exec` propagate `SyntaxError`

Aperta
#139,324 9 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

3.14 3.15 docs topic-subinterpreters
Lingua principale
Python
Stelle
77.2k
Fork
35.9k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

Bug report

Bug description:

Hi,

I am testing the concurrent.interpreters feature from Python 3.14rc3 (the latest current rc).

The subinterpreter seems to behave in a surprising way when encountering syntax errors. For example, in the following code:

from concurrent import interpreters

interpr = interpreters.create()

def exec_catching_errors(code: str) -> None:
    try:
        interpr.exec(code)
    except interpreters.ExecutionFailed as e:
        print(f"There was an error: {e}")
    print("The function ends")


exec_catching_errors("print(1/0)")
exec_catching_errors("print 1")  # this is the surprising line

# the whole script dies with an uncaught SyntaxError
  • trying to execute print(1/0) causes an interpreters.ExecutionFailed that correctly wraps a ZeroDivisionError.
  • trying to execute print 1 causes a bare SyntaxError, whereas I would have expected a subclass of interpreters.InterpreterError wrapping the SyntaxError.

Is this intended behaviour, a bug, or something that simply needs to be better documented?

Thanks

CPython versions tested on:

3.14

Operating systems tested on:

Linux

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 con l’implementazione di concurrent.interpreters.Interpreter.exec e riproduci i due frammenti di codice del report su Python 3.14. Determina la gestione prevista di SyntaxError rispetto a ExecutionFailed, quindi aggiungi o aggiorna test mirati in modo che il comportamento sia esplicito e coerente.

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

Valutazione

Stack tecnologico
python
Ambito
backend
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.