python / python/cpython

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

Đang mở
#139,324 9 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

3.14 3.15 docs topic-subinterpreters
Ngôn ngữ chính
Python
Star
77.2k
Fork
35.9k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với việc triển khai concurrent.interpreters.Interpreter.exec và tái hiện hai đoạn mã trong báo cáo trên Python 3.14. Xác định cách xử lý dự kiến đối với SyntaxError so với ExecutionFailed, sau đó thêm hoặc cập nhật các bài kiểm thử tập trung để hành vi được rõ ràng và nhất quán.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
backend
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.