Closed `sys.stdout` causes an endless stream of tracebacks in the repl
Chưa có ai nhận issue này.
- 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:
Steps to reproduce:
Run Python 3.14.7 and enter the following:
import sys
f = open("file.txt", "w")
sys.stdout = f
f.close()
After the file is closed, the REPL attempts to display the next prompt.
Actual behavior:
The REPL repeatedly raises:
ValueError: I/O operation on closed file
This results in a very large stream of repeated tracebacks instead of returning to a usable prompt.
The traceback points to _pyrepl and eventually to:
_colorize.py", line 313, in can_colorize
return os.isatty(file.fileno())
ValueError: I/O operation on closed file
Expected behavior:
The REPL should handle a closed sys.stdout gracefully instead of repeatedly emitting tracebacks.
Environment:
Python: 3.14.7
OS: Fedora Linux 44 (Workstation Edition) x86_64
CPython versions tested on:
3.14
Operating systems tested on:
Linux
Linked PRs
- gh-157590
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với traceback của _pyrepl và entry point can_colorize trong _colorize.py, khoảng dòng 313, sau đó tái hiện trường hợp sys.stdout bị đóng trong REPL Python 3.14. Hoàn tất có nghĩa là stdout bị đóng không còn tạo ra một chuỗi traceback vô tận và REPL xử lý đúng prompt tiếp theo.
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
- cli
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 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
- 25/100