(original) (raw)

--- Python-2.2.3/Modules/readline.c 2003-03-29 14:25:18.000000000 -0800 +++ Python-2.2.3_new/Modules/readline.c 2003-06-27 07:12:39.000000000 -0700 @@ -4,6 +4,9 @@ * * More recently, it was largely rewritten by Guido van Rossum who is * now maintaining it. + * + * Modified by Keith Dart kdart@ironport.com to support checking for + * signals. */ /* Standard definitions */ @@ -25,7 +28,6 @@ extern DL_IMPORT(int) (*PyOS_InputHook)(void); extern DL_IMPORT(char) *(*PyOS_ReadlineFunctionPointer)(char *); - /* Exported function to send one line to readline's init file parser */ static PyObject * @@ -197,6 +199,9 @@ static PyThreadState *pre_input_hook_tstate = NULL; #endif +/* added by kwd - try and get signals called when idle. */ +static PyThreadState *event_tstate = NULL; + static PyObject * set_startup_hook(PyObject *self, PyObject *args) { @@ -605,6 +610,20 @@ } +static int +EventHook(void) +{ +#ifdef WITH_THREAD + PyEval_RestoreThread(event_tstate); +#endif + (void)PyErr_CheckSignals(); +#ifdef WITH_THREAD + event_tstate = PyEval_SaveThread(); +#endif + return 0; + +} + /* Initialize the module */ static char doc_module[] = @@ -620,5 +639,14 @@ if (isatty(fileno(stdin))) { PyOS_ReadlineFunctionPointer = call_readline; setup_readline(); + + /* added by kwd - try and get signals called when idle. */ + if (PyOS_InputHook == NULL) { +#ifdef WITH_THREAD + event_tstate = PyThreadState_Get(); +#endif + PyOS_InputHook = EventHook; + } + } } /kdart@ironport.com