user202729
Put the following in `a.py`:
```
#!/bin/python3
try:
while True: pass
except KeyboardInterrupt:
pass
```
Run with `python a.py`:
```
$ python a.py
```
Press `Ctrl+C` to interrupt it:
```
^CTraceback (most recent call last):
File "/tmp/a.py", line 3, in <module>
while True: pass
KeyboardInterrupt
```
Why is the error still printed and not captured?
Python version: Python 3.11.3, on Linux.
Top Answer
daviewales
I'm not able to reproduce your question.
I copied and pasted your code and ran it, and it exits without printing a traceback.