bpo-30946: Remove obsolete fallback code in readline module (#2738)

* Remove obsolete fallback code in readline module

* Add NEWS

* Remove obsolete include

* Fix macro on Windows
This commit is contained in:
Antoine Pitrou 2017-07-18 17:05:03 +02:00 committed by GitHub
parent efa26bcd50
commit f474c5a3f3
7 changed files with 8 additions and 108 deletions

View File

@ -38,11 +38,12 @@ PyAPI_DATA(PyTypeObject) PyStdPrinter_Type;
#endif /* Py_LIMITED_API */
/* A routine to check if a file descriptor can be select()-ed. */
#ifdef HAVE_SELECT
#define _PyIsSelectable_fd(FD) ((unsigned int)(FD) < (unsigned int)FD_SETSIZE)
#else
#ifdef _MSC_VER
/* On Windows, any socket fd can be select()-ed, no matter how high */
#define _PyIsSelectable_fd(FD) (1)
#endif /* HAVE_SELECT */
#else
#define _PyIsSelectable_fd(FD) ((unsigned int)(FD) < (unsigned int)FD_SETSIZE)
#endif
#ifdef __cplusplus
}

View File

@ -0,0 +1,2 @@
Remove obsolete code in readline module for platforms where GNU readline is
older than 2.1 or where select() is not available.

View File

@ -7,7 +7,6 @@
/* Standard definitions */
#include "Python.h"
#include <stddef.h>
#include <setjmp.h>
#include <signal.h>
#include <errno.h>
#include <sys/time.h>
@ -1180,9 +1179,6 @@ setup_readline(readlinestate *mod_state)
/* Wrapper around GNU readline that handles signals differently. */
#if defined(HAVE_RL_CALLBACK) && defined(HAVE_SELECT)
static char *completed_input_string;
static void
rlhandler(char *text)
@ -1262,47 +1258,6 @@ readline_until_enter_or_signal(const char *prompt, int *signal)
}
#else
/* Interrupt handler */
static jmp_buf jbuf;
/* ARGSUSED */
static void
onintr(int sig)
{
longjmp(jbuf, 1);
}
static char *
readline_until_enter_or_signal(const char *prompt, int *signal)
{
PyOS_sighandler_t old_inthandler;
char *p;
*signal = 0;
old_inthandler = PyOS_setsig(SIGINT, onintr);
if (setjmp(jbuf)) {
#ifdef HAVE_SIGRELSE
/* This seems necessary on SunOS 4.1 (Rasmus Hahn) */
sigrelse(SIGINT);
#endif
PyOS_setsig(SIGINT, old_inthandler);
*signal = 1;
return NULL;
}
rl_event_hook = PyOS_InputHook;
p = readline(prompt);
PyOS_setsig(SIGINT, old_inthandler);
return p;
}
#endif /*defined(HAVE_RL_CALLBACK) && defined(HAVE_SELECT) */
static char *
call_readline(FILE *sys_stdin, FILE *sys_stdout, const char *prompt)
{

View File

@ -530,9 +530,6 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
/* Define if you have readlink. */
/* #undef HAVE_READLINK */
/* Define if you have select. */
/* #undef HAVE_SELECT */
/* Define if you have setpgid. */
/* #undef HAVE_SETPGID */

44
configure vendored
View File

@ -15228,50 +15228,6 @@ $as_echo "#define HAVE_LIBREADLINE 1" >>confdefs.h
fi
# check for readline 2.1
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_callback_handler_install in -lreadline" >&5
$as_echo_n "checking for rl_callback_handler_install in -lreadline... " >&6; }
if ${ac_cv_lib_readline_rl_callback_handler_install+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lreadline $READLINE_LIBS $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char rl_callback_handler_install ();
int
main ()
{
return rl_callback_handler_install ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_readline_rl_callback_handler_install=yes
else
ac_cv_lib_readline_rl_callback_handler_install=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_rl_callback_handler_install" >&5
$as_echo "$ac_cv_lib_readline_rl_callback_handler_install" >&6; }
if test "x$ac_cv_lib_readline_rl_callback_handler_install" = xyes; then :
$as_echo "#define HAVE_RL_CALLBACK 1" >>confdefs.h
fi
# check for readline 2.2
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

View File

@ -4786,11 +4786,6 @@ else
[Define if you have the readline library (-lreadline).])
fi
# check for readline 2.1
AC_CHECK_LIB(readline, rl_callback_handler_install,
AC_DEFINE(HAVE_RL_CALLBACK, 1,
[Define if you have readline 2.1]), ,$READLINE_LIBS)
# check for readline 2.2
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
[have_readline=yes],

View File

@ -733,9 +733,6 @@
/* Define if readline supports append_history */
#undef HAVE_RL_APPEND_HISTORY
/* Define if you have readline 2.1 */
#undef HAVE_RL_CALLBACK
/* Define if you can turn off readline's signal handling. */
#undef HAVE_RL_CATCH_SIGNAL
@ -778,9 +775,6 @@
/* Define to 1 if you have the `sched_setscheduler' function. */
#undef HAVE_SCHED_SETSCHEDULER
/* Define to 1 if you have the `select' function. */
#undef HAVE_SELECT
/* Define to 1 if you have the `sem_getvalue' function. */
#undef HAVE_SEM_GETVALUE