Skip to content

concurrent.interpreters.Interpreter.exec propagate SyntaxError #139324

@muxator

Description

@muxator

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixes3.15new features, bugs and security fixesdocsDocumentation in the Doc dirtopic-subinterpreters

    Projects

    Status

    Todo

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions