Skip to content

gh-105323: Add special workround for macOS default editline #108633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

11 changes: 10 additions & 1 deletion 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 @@ -5826,9 +5827,17 @@ AC_ARG_WITH(
[AC_MSG_ERROR([proper usage is --with(out)-readline@<:@=editline|readline|no@:>@])]
)
],
[with_readline=readline]
[with_readline=default]
)

dnl gh-105323: Need to handle the macOS editline as an alias of readline.
AS_VAR_IF([with_readline], [default], [
AS_CASE([$ac_sys_system/$ac_sys_release],
[Darwin/*], [AC_DEFINE([WITH_APPLE_READLINE])],
[])]
)
AS_VAR_IF([with_readline], [default], [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