[Python-bugs-list] KeyboardInterrupt while waiting for sys.ps2 input kills interpreter (PR#309)

skip@mojam.com skip@mojam.com
Fri, 28 Apr 2000 17:00:41 -0400 (EDT)


Full_Name: Skip Montanaro
Version: 1.5.2, 1.6a2
OS: Linux
Submission from: beluga.mojam.com (199.249.165.173)


If you hit Ctrl-C while the Python interpreter is sitting at the ps2 prompt the
interpreter exits instead of returning you to the top-level prompt.

% python
Python 1.5.2+ (#12, Feb 17 2000, 14:52:05)  [GCC pgcc-2.91.66 19990314
(egcs-1.1.2 release)] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> if 1:
... 

% PYTHONSTARTUP= ./python
Python 1.6a2 (#7, Apr 24 2000, 23:02:54)  [GCC pgcc-2.91.66 19990314 (egcs-1.1.2
release)] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> if 1:
... 

When run under gdb's control, you can see what's happening:

% gdb ./python
GNU gdb 4.18
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-mandrake-linux"...
(gdb) set env PYTHONSTARTUP ""
(gdb) run
Starting program: /home/beluga/skip/src/python/dist/src/./python 
Python 1.6a2 (#7, Apr 24 2000, 23:02:54)  [GCC pgcc-2.91.66 19990314 (egcs-1.1.2
release)] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> if 1:
... 
Program received signal SIGINT, Interrupt.
0x4013bf14 in __libc_read () from /lib/libc.so.6
(gdb) bt
#0  0x4013bf14 in __libc_read () from /lib/libc.so.6
(gdb) c
Continuing.

  File "<stdin>", line 2
    
    ^
SyntaxError: invalid syntax
>>> 

It appears that SIGINT isn't handled properly when awaiting console input in
certain circumstances.  If you can entice the program to continue, things work
okay.  I don't know interrupt handling from a hole in the ground or I'd
investigate further.  It is quite annoying, especially considering that
Python's input history isn't continuous across sessions...


Skip