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
Bug report
Bug description:
Steps to reproduce:
Run Python 3.14.7 and enter the following:
After the file is closed, the REPL attempts to display the next prompt.
Actual behavior:
The REPL repeatedly raises:
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:
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