So I start a really long loop, then Ctrl+C during the loop execution.
Then I start a try
statement, hit enter, then hit Ctrl+C. Then python.exe says “lost sys.stderr”.
>>> for p in range(10**9):pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyboardInterrupt
>>> try:
... # I clicked Ctrl+C on this line
File "<stdin>", line 1
try:
object address : 00000288CFC191C0
object refcount : 3
object type : 00007FF8396DAE70
object type name: IndentationError
object repr : IndentationError("expected an indented block after 'try' statement on line 1", ('<stdin>', 1, 5, 'try:', 1, -1))
lost sys.stderr
>>> import sys
>>> sys.stderr
<_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>
>>> raise
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: No active exception to reraise
>>>
There doesn’t seem to be any problem with sys.stderr, so exactly what happened?
New contributor
Lucenaposition is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.