Skip to content

Commit

Permalink
pythongh-105223: Add special workround for macOS default editline
Browse files Browse the repository at this point in the history
  • Loading branch information
corona10 committed Aug 30, 2023
1 parent 30305d6 commit 6b4b134
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
16 changes: 14 additions & 2 deletions Modules/readline.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
20 changes: 19 additions & 1 deletion configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -5822,13 +5823,21 @@ 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@:>@])]
)
],
[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
Expand Down
3 changes: 3 additions & 0 deletions pyconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6b4b134

Please sign in to comment.