[Python-Dev] Where to put the interrupt module?

Guido van Rossum guido@python.org
2003年6月12日 16:07:33 -0400


> I haven't looked, but is it possible to make it raise an arbitrary
> exception? Last time I read the PyErr_CheckSignals code it looked possible. 
> (That was yesterday, actually, regarding problems with the SSL module and
> KeyboardInterrupts).

The interrupt module currently uses PyErr_SetInterrupt(), which can
only raise KeyboardInterrupt.
Let's not generalize this until there's a need. Then, let whoever has
the need add the generalization.
I'm actually a bit wary of such a generalization, because
KeyboardInterrupt is currently the only *asynchronous* exception that
code needs to worry about. There is plenty of code that gives
KeyboardInterrupt special treatment, typically of the form:
 while MoreWorkToDo:
 try:
	 ...run a chunk of work which may raise arbitrary exceptions...
 except KeyboardInterrupt:
	 raise # Don't keep going in this case
 except:
	 ...report the error and continue...
--Guido van Rossum (home page: http://www.python.org/~guido/)

AltStyle によって変換されたページ (->オリジナル) /