This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author xxm
Recipients xxm
Date 2021-03-24.03:04:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1616555069.73.0.540309240427.issue43610@roundup.psfhosted.org>
In-reply-to
Content
Python interpreter will exit when using Ctrl C to interrupt some Python module functions with read operations. e.g.  sndhdr.what(0), pdb.find_function('abs/'*100000,False), mimetypes.read_mime_types(0).  This is not the expected behavior.  Ctrl C is to raise a KeyboardInterrupt, it should not crash Python and make interpreter exit.

Reproduce:
1. type 'python3' in command console;
2. type 'import sndhdr;sndhdr.what(0)'
3. type ctrl C

Expected behavior:  type ctrl c, raise a KeyboardInterrupt,  Python does not exit.
========================================
xxm@xxm-System-Product-Name:~$ python
Python 3.9.2 (default, Mar 12 2021, 15:08:35)
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
KeyboardInterrupt
>>>
========================================

Unexpected behavior:  type ctrl c, raise a KeyboardInterrupt, Python exits.
===========================================================
xxm@xxm-System-Product-Name:~$ python
Python 3.9.2 (default, Mar 12 2021, 15:08:35)
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sndhdr;sndhdr.what(0)
^CTraceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/xxm/Desktop/apifuzz/Python-3.9.2/Lib/sndhdr.py", line 54, in what
    res = whathdr(filename)
  File "/home/xxm/Desktop/apifuzz/Python-3.9.2/Lib/sndhdr.py", line 61, in whathdr
    h = f.read(512)
KeyboardInterrupt
>>>

xxm@xxm-System-Product-Name:~$
===========================================================

System: Ubuntu 16.04
History
Date User Action Args
2021-03-24 03:04:29xxmsetrecipients: + xxm
2021-03-24 03:04:29xxmsetmessageid: <1616555069.73.0.540309240427.issue43610@roundup.psfhosted.org>
2021-03-24 03:04:29xxmlinkissue43610 messages
2021-03-24 03:04:29xxmcreate