python / python/cpython

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

オープン
#139,324 コメント 9 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

3.14 3.15 docs topic-subinterpreters
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

concurrent.interpreters.Interpreter.exec の実装から始め、Python 3.14 でレポートにある 2 つのコードスニペットを再現します。SyntaxError と ExecutionFailed をどのように扱うべきかを確認し、その後、動作が明示的かつ一貫したものになるよう、焦点を絞ったテストを追加または更新します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
backend
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。