diff --git a/Modules/readline.c b/Modules/readline.c index 2531b236b6ef178..9dc717a4587cbd6 100644 --- a/Modules/readline.c +++ b/Modules/readline.c @@ -1019,10 +1019,16 @@ on_hook(PyObject *func) static int #if defined(_RL_FUNCTION_TYPEDEF) on_startup_hook(void) +{ +#elif defined(__APPLE__) && defined(WITH_APPLE_READLINE) +on_startup_hook(const char *text, int state) +{ + (void)text; + (void)state; #else on_startup_hook(void) -#endif { +#endif int r; PyGILState_STATE gilstate = PyGILState_Ensure(); r = on_hook(readlinestate_global->startup_hook); @@ -1034,10 +1040,16 @@ on_startup_hook(void) static int #if defined(_RL_FUNCTION_TYPEDEF) on_pre_input_hook(void) +{ +#elif defined(__APPLE__) && defined(WITH_APPLE_READLINE) +on_pre_input_hook(const char *text, int state) +{ + (void)text; + (void)state; #else on_pre_input_hook(void) -#endif { +#endif int r; PyGILState_STATE gilstate = PyGILState_Ensure(); r = on_hook(readlinestate_global->pre_input_hook); diff --git a/configure b/configure index 57e3307266c0b17..f022efb42c019f7 100755 --- a/configure +++ b/configure @@ -23755,6 +23755,7 @@ fi + # Check whether --with-readline was given. if test ${with_readline+y} then : @@ -23772,11 +23773,28 @@ then : esac else $as_nop - with_readline=readline + with_readline=default fi +if test "x$with_readline" = xdefault +then : + + case $ac_sys_system/$ac_sys_release in #( + Darwin/*) : + printf "%s\n" "#define WITH_APPLE_READLINE 1" >>confdefs.h + ;; #( + *) : + ;; +esac + +fi +if test "x$with_readline" = xdefault +then : + with_readline=readline +fi + if test "x$with_readline" = xreadline then : diff --git a/configure.ac b/configure.ac index 6fb6e1106470368..fdec6eb46da690e 100644 --- a/configure.ac +++ b/configure.ac @@ -5813,6 +5813,7 @@ dnl library (tinfo ncursesw ncurses termcap). We now assume that libreadline dnl or readline.pc provide correct linker information. AH_TEMPLATE([WITH_EDITLINE], [Define to build the readline module against libedit.]) +AH_TEMPLATE([WITH_APPLE_READLINE], [Define to build the readline module agains apple builtin readline.]) AC_ARG_WITH( [readline], @@ -5822,6 +5823,7 @@ AC_ARG_WITH( AS_CASE([$with_readline], [editline|edit], [with_readline=edit], [yes|readline], [with_readline=readline], + [apple], [with_readline=apple], [no], [], [AC_MSG_ERROR([proper usage is --with(out)-readline@<:@=editline|readline|no@:>@])] ) @@ -5829,6 +5831,13 @@ AC_ARG_WITH( [with_readline=readline] ) +dnl gh-105323: Need to handle the macOS editline as an alias of readline. +AS_VAR_IF([with_readline], [apple], [ + AS_CASE([$ac_sys_system/$ac_sys_release], + [Darwin/*], [AC_DEFINE([WITH_APPLE_READLINE]) with_readline=readline], + [])] +) + AS_VAR_IF([with_readline], [readline], [ PKG_CHECK_MODULES([LIBREADLINE], [readline], [ LIBREADLINE=readline diff --git a/pyconfig.h.in b/pyconfig.h.in index 418ccade8e8bb15..1c34784aae74ab9 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -1791,6 +1791,9 @@ /* Define if WINDOW in curses.h offers a field _flags. */ #undef WINDOW_HAS_FLAGS +/* Define to build the readline module agains apple builtin readline. */ +#undef WITH_APPLE_READLINE + /* Define if you want build the _decimal module using a coroutine-local rather than a thread-local context */ #undef WITH_DECIMAL_CONTEXTVAR