[Patches] [ python-Patches-706406 ] fix bug #685846: raw_input defers signals

SourceForge.net noreply@sourceforge.net
Wed, 19 Mar 2003 09:47:17 -0800


Patches item #706406, was opened at 2003-03-19 17:46
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=706406&group_id=5470

>Category: Core (C code)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Michael Stone (mbrierst)
Assigned to: Nobody/Anonymous (nobody)
Summary: fix bug #685846: raw_input defers signals

Initial Comment:
This patch attempts to fix raw_input so it
can be interrupted by signals.  In the process
it allows SIGINT handling to be honored by
raw_input.  (right now SIGINT always interrupts
regardless of any installed handlers)

Effects:
Signals are handled with their installed handlers
and when those handlers raise exceptions those
exceptions are raised by raw_input.  If an
exception is not raised, raw_input continues
collecting input as if nothing had happened.
This can be problematic if the signal causes
output to appear on the screen, messing up
the input line, or if someone using the
readline module was in the middle of a
complex operation, like a reverse search,
in which case that operation will be
cancelled.  It would be easy to instead
print a message ("Signal Interruption")
and continue input on a new line for the
readline library, but this couldn't happen
in myreadline.c as we can't retrieve the
partially entered input.

Backwards compatibility:
This patch requires the readline handler
(either call_readline or PyOS_StdioReadline
generally) to be called while holding the
global interpreter lock.  It is then
responsible for releasing the GIL before doing
blocking input. This will cause problems
for anyone who has written an extension
that installs a custom readline handler.
In python code, anyone using signals and
expecting raw_input not to be interrupted
by them will have problems (but this seems
unlikely).

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=706406&group_id=5470