`concurrent.interpreters.Interpreter.exec` propagate `SyntaxError`
未關閉
還沒有人認領這個 Issue。
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 aninterpreters.ExecutionFailedthat correctly wraps aZeroDivisionError. - trying to execute
print 1causes a bareSyntaxError, whereas I would have expected a subclass ofinterpreters.InterpreterErrorwrapping theSyntaxError.
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
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 concurrent.interpreters.Interpreter.exec 的實作開始,並在 Python 3.14 上重現報告中的兩個程式碼片段。確定相對於 ExecutionFailed 應如何處理 SyntaxError,然後新增或更新具針對性的測試,使行為明確且一致。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- backend
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100