[Python-checkins] CVS: python/dist/src/Modules readline.c,2.30,2.31
Guido van Rossum
python-dev@python.org
Sat, 16 Sep 2000 09:37:56 -0700
Update of /cvsroot/python/python/dist/src/Modules
In directory slayer.i.sourceforge.net:/tmp/cvs-serv646
Modified Files:
readline.c
Log Message:
Use PyOS_setsig() instead of directly calling signal() or sigaction().
This fixes the first half of bug #110611: the immediate exit when ^C
is hit when readline and threads are configured.
Also added a new module variable, readline.library_version.
Index: readline.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v
retrieving revision 2.30
retrieving revision 2.31
diff -C2 -r2.30 -r2.31
*** readline.c 2000/09/01 02:43:38 2.30
--- readline.c 2000/09/16 16:37:53 2.31
***************
*** 448,453 ****
size_t n;
char *p, *q;
! void (*old_inthandler)(int);
! old_inthandler = signal(SIGINT, onintr);
if (setjmp(jbuf)) {
#ifdef HAVE_SIGRELSE
--- 448,454 ----
size_t n;
char *p, *q;
! PyOS_sighandler_t old_inthandler;
!
! old_inthandler = PyOS_setsig(SIGINT, onintr);
if (setjmp(jbuf)) {
#ifdef HAVE_SIGRELSE
***************
*** 455,464 ****
sigrelse(SIGINT);
#endif
! signal(SIGINT, old_inthandler);
return NULL;
}
rl_event_hook = PyOS_InputHook;
p = readline(prompt);
! signal(SIGINT, old_inthandler);
/* We must return a buffer allocated with PyMem_Malloc. */
--- 456,465 ----
sigrelse(SIGINT);
#endif
! PyOS_setsig(SIGINT, old_inthandler);
return NULL;
}
rl_event_hook = PyOS_InputHook;
p = readline(prompt);
! PyOS_setsig(SIGINT, old_inthandler);
/* We must return a buffer allocated with PyMem_Malloc. */
***************
*** 494,501 ****
initreadline(void)
{
! PyObject *m;
m = Py_InitModule4("readline", readline_methods, doc_module,
(PyObject *)NULL, PYTHON_API_VERSION);
if (isatty(fileno(stdin))) {
PyOS_ReadlineFunctionPointer = call_readline;
--- 495,508 ----
initreadline(void)
{
! PyObject *m, *d, *v;
m = Py_InitModule4("readline", readline_methods, doc_module,
(PyObject *)NULL, PYTHON_API_VERSION);
+
+ d = PyModule_GetDict(m);
+ v = PyString_FromString(rl_library_version);
+ PyDict_SetItemString(d, "library_version", v);
+ Py_XDECREF(v);
+
if (isatty(fileno(stdin))) {
PyOS_ReadlineFunctionPointer = call_readline;