mirror of
https://github.com/python/cpython
synced 2024-09-05 00:05:39 +00:00
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:
parent
efa26bcd50
commit
f474c5a3f3
|
@ -38,11 +38,12 @@ PyAPI_DATA(PyTypeObject) PyStdPrinter_Type;
|
||||||
#endif /* Py_LIMITED_API */
|
#endif /* Py_LIMITED_API */
|
||||||
|
|
||||||
/* A routine to check if a file descriptor can be select()-ed. */
|
/* A routine to check if a file descriptor can be select()-ed. */
|
||||||
#ifdef HAVE_SELECT
|
#ifdef _MSC_VER
|
||||||
#define _PyIsSelectable_fd(FD) ((unsigned int)(FD) < (unsigned int)FD_SETSIZE)
|
/* On Windows, any socket fd can be select()-ed, no matter how high */
|
||||||
|
#define _PyIsSelectable_fd(FD) (1)
|
||||||
#else
|
#else
|
||||||
#define _PyIsSelectable_fd(FD) (1)
|
#define _PyIsSelectable_fd(FD) ((unsigned int)(FD) < (unsigned int)FD_SETSIZE)
|
||||||
#endif /* HAVE_SELECT */
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.
|
|
@ -7,7 +7,6 @@
|
||||||
/* Standard definitions */
|
/* Standard definitions */
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <setjmp.h>
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
@ -1180,10 +1179,7 @@ setup_readline(readlinestate *mod_state)
|
||||||
|
|
||||||
/* Wrapper around GNU readline that handles signals differently. */
|
/* Wrapper around GNU readline that handles signals differently. */
|
||||||
|
|
||||||
|
static char *completed_input_string;
|
||||||
#if defined(HAVE_RL_CALLBACK) && defined(HAVE_SELECT)
|
|
||||||
|
|
||||||
static char *completed_input_string;
|
|
||||||
static void
|
static void
|
||||||
rlhandler(char *text)
|
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 *
|
static char *
|
||||||
call_readline(FILE *sys_stdin, FILE *sys_stdout, const char *prompt)
|
call_readline(FILE *sys_stdin, FILE *sys_stdout, const char *prompt)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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. */
|
/* Define if you have readlink. */
|
||||||
/* #undef HAVE_READLINK */
|
/* #undef HAVE_READLINK */
|
||||||
|
|
||||||
/* Define if you have select. */
|
|
||||||
/* #undef HAVE_SELECT */
|
|
||||||
|
|
||||||
/* Define if you have setpgid. */
|
/* Define if you have setpgid. */
|
||||||
/* #undef HAVE_SETPGID */
|
/* #undef HAVE_SETPGID */
|
||||||
|
|
||||||
|
|
44
configure
vendored
44
configure
vendored
|
@ -15228,50 +15228,6 @@ $as_echo "#define HAVE_LIBREADLINE 1" >>confdefs.h
|
||||||
|
|
||||||
fi
|
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
|
# check for readline 2.2
|
||||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||||
/* end confdefs.h. */
|
/* end confdefs.h. */
|
||||||
|
|
|
@ -4786,11 +4786,6 @@ else
|
||||||
[Define if you have the readline library (-lreadline).])
|
[Define if you have the readline library (-lreadline).])
|
||||||
fi
|
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
|
# check for readline 2.2
|
||||||
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
|
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
|
||||||
[have_readline=yes],
|
[have_readline=yes],
|
||||||
|
|
|
@ -733,9 +733,6 @@
|
||||||
/* Define if readline supports append_history */
|
/* Define if readline supports append_history */
|
||||||
#undef HAVE_RL_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. */
|
/* Define if you can turn off readline's signal handling. */
|
||||||
#undef HAVE_RL_CATCH_SIGNAL
|
#undef HAVE_RL_CATCH_SIGNAL
|
||||||
|
|
||||||
|
@ -778,9 +775,6 @@
|
||||||
/* Define to 1 if you have the `sched_setscheduler' function. */
|
/* Define to 1 if you have the `sched_setscheduler' function. */
|
||||||
#undef HAVE_SCHED_SETSCHEDULER
|
#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. */
|
/* Define to 1 if you have the `sem_getvalue' function. */
|
||||||
#undef HAVE_SEM_GETVALUE
|
#undef HAVE_SEM_GETVALUE
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue