[issue706406] fix bug #685846: raw_input defers signals

Michael Stone report at bugs.python.org
Thu Aug 19 03:07:25 CEST 2010


Michael Stone <mbrierst at gmail.com> added the comment:

Wow, you wait 3/4 of a decade or so and the status of these bugs does tend to change on you.  I'm not sure it's fixed, but it is different.  Here's a test script for you:

import readline
import signal
def handle(a,b):
   print "received signal"
signal.signal(signal.SIGALRM, handle)
signal.alarm(5)
name = raw_input('Please enter your name within 5 seconds: ')
print name

The behavior of this script as is, since at least python 2.5 or so, is after 5 seconds to run the signal handler and then keep waiting for input (assuming you've got readline on your box of course).  I like this behavior, everything seems good to me so far.

Now comment out the "import readline", and suddenly you're getting an EOFError after the signal handler runs normally.  Still better than it used to be in 2003, but I'm not sure if this inconsistency is okay or not.

Now let's throw another wrench in the system.  Raise an exception in the signal handler.  Suddenly both are consistent again with and without readline, both raising the exception from the signal handler.  Sounds good to me.

So I guess someone has to decide, is this EOFError a new bug?  Or is this inconsistency acceptable and/or too hard to fix?  I haven't looked at the code in forever, so I can't speak for how hard it would be to fix.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue706406>
_______________________________________


More information about the Python-bugs-list mailing list