diff options
-rw-r--r-- | Include/fileobject.h | 9 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2017-07-17-12-32-47.bpo-30946.DUo-uA.rst | 2 | ||||
-rw-r--r-- | Modules/readline.c | 47 | ||||
-rw-r--r-- | PC/pyconfig.h | 3 | ||||
-rwxr-xr-x | configure | 44 | ||||
-rw-r--r-- | configure.ac | 5 | ||||
-rw-r--r-- | pyconfig.h.in | 6 |
7 files changed, 8 insertions, 108 deletions
diff --git a/Include/fileobject.h b/Include/fileobject.h index 1dde17e..0b1678e 100644 --- a/Include/fileobject.h +++ b/Include/fileobject.h @@ -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) +#ifdef _MSC_VER + /* On Windows, any socket fd can be select()-ed, no matter how high */ + #define _PyIsSelectable_fd(FD) (1) #else - #define _PyIsSelectable_fd(FD) (1) -#endif /* HAVE_SELECT */ + #define _PyIsSelectable_fd(FD) ((unsigned int)(FD) < (unsigned int)FD_SETSIZE) +#endif #ifdef __cplusplus } diff --git a/Misc/NEWS.d/next/Library/2017-07-17-12-32-47.bpo-30946.DUo-uA.rst b/Misc/NEWS.d/next/Library/2017-07-17-12-32-47.bpo-30946.DUo-uA.rst new file mode 100644 index 0000000..0d06a7d --- /dev/null +++ b/Misc/NEWS.d/next/Library/2017-07-17-12-32-47.bpo-30946.DUo-uA.rst @@ -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. diff --git a/Modules/readline.c b/Modules/readline.c index 7d32c21..f4a5e5a 100644 --- a/Modules/readline.c +++ b/Modules/readline.c @@ -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,10 +1179,7 @@ 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 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) { diff --git a/PC/pyconfig.h b/PC/pyconfig.h index bab9d5a..46ff6f0 100644 --- a/PC/pyconfig.h +++ b/PC/pyconfig.h @@ -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 */ @@ -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. */ diff --git a/configure.ac b/configure.ac index 8253102..a5da830 100644 --- a/configure.ac +++ b/configure.ac @@ -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], diff --git a/pyconfig.h.in b/pyconfig.h.in index b4d1f1b..0dd05aa 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -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 |