]> granicus.if.org Git - python/commitdiff
bpo-30946: Remove obsolete fallback code in readline module (#2738)
authorAntoine Pitrou <pitrou@free.fr>
Tue, 18 Jul 2017 15:05:03 +0000 (17:05 +0200)
committerGitHub <noreply@github.com>
Tue, 18 Jul 2017 15:05:03 +0000 (17:05 +0200)
* Remove obsolete fallback code in readline module

* Add NEWS

* Remove obsolete include

* Fix macro on Windows

Include/fileobject.h
Misc/NEWS.d/next/Library/2017-07-17-12-32-47.bpo-30946.DUo-uA.rst [new file with mode: 0644]
Modules/readline.c
PC/pyconfig.h
configure
configure.ac
pyconfig.h.in

index 1dde17e1efc411b67301e78efd69ef1b29ba4c70..0b1678ee8dac678dd66de53fad2481d44f196f7f 100644 (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)
+#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 (file)
index 0000000..0d06a7d
--- /dev/null
@@ -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.
index 7d32c21f42d63844840c907aac5450e02221529f..f4a5e5adcb030fcc918cc5e3cfecd46153dc06ee 100644 (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,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)
 {
index bab9d5aef9de6d7739fbb8cf75ff6ac0f75c596e..46ff6f0fe56bc82de5e719c547ef9f2a2ed732a3 100644 (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 */
 
index 3a28cad9678a355870019396e653165517b5cf0e..a6f7d2bd7f0d9e1ba8aef7e61229e74a552f6506 100755 (executable)
--- a/configure
+++ b/configure
@@ -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.  */
index 8253102fc1debc1d7b923ba19bdc5965d4fa2793..a5da830e89623c46b263e38532c3785ff0d1ef0b 100644 (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],
index b4d1f1b50384e4db1e5605fe4089b1d7ffa598f2..0dd05aa65b8a4f81a28227621047fc3bdba3778a 100644 (file)
 /* 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
 
 /* 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