Skip to content

Commit 6b4b134

Browse files
committed
pythongh-105223: Add special workround for macOS default editline
1 parent 30305d6 commit 6b4b134

File tree

4 files changed

+45
-3
lines changed

4 files changed

+45
-3
lines changed

Modules/readline.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,10 +1019,16 @@ on_hook(PyObject *func)
10191019
static int
10201020
#if defined(_RL_FUNCTION_TYPEDEF)
10211021
on_startup_hook(void)
1022+
{
1023+
#elif defined(__APPLE__) && defined(WITH_APPLE_READLINE)
1024+
on_startup_hook(const char *text, int state)
1025+
{
1026+
(void)text;
1027+
(void)state;
10221028
#else
10231029
on_startup_hook(void)
1024-
#endif
10251030
{
1031+
#endif
10261032
int r;
10271033
PyGILState_STATE gilstate = PyGILState_Ensure();
10281034
r = on_hook(readlinestate_global->startup_hook);
@@ -1034,10 +1040,16 @@ on_startup_hook(void)
10341040
static int
10351041
#if defined(_RL_FUNCTION_TYPEDEF)
10361042
on_pre_input_hook(void)
1043+
{
1044+
#elif defined(__APPLE__) && defined(WITH_APPLE_READLINE)
1045+
on_pre_input_hook(const char *text, int state)
1046+
{
1047+
(void)text;
1048+
(void)state;
10371049
#else
10381050
on_pre_input_hook(void)
1039-
#endif
10401051
{
1052+
#endif
10411053
int r;
10421054
PyGILState_STATE gilstate = PyGILState_Ensure();
10431055
r = on_hook(readlinestate_global->pre_input_hook);

configure

Lines changed: 19 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5813,6 +5813,7 @@ dnl library (tinfo ncursesw ncurses termcap). We now assume that libreadline
58135813
dnl or readline.pc provide correct linker information.
58145814

58155815
AH_TEMPLATE([WITH_EDITLINE], [Define to build the readline module against libedit.])
5816+
AH_TEMPLATE([WITH_APPLE_READLINE], [Define to build the readline module agains apple builtin readline.])
58165817

58175818
AC_ARG_WITH(
58185819
[readline],
@@ -5822,13 +5823,21 @@ AC_ARG_WITH(
58225823
AS_CASE([$with_readline],
58235824
[editline|edit], [with_readline=edit],
58245825
[yes|readline], [with_readline=readline],
5826+
[apple], [with_readline=apple],
58255827
[no], [],
58265828
[AC_MSG_ERROR([proper usage is --with(out)-readline@<:@=editline|readline|no@:>@])]
58275829
)
58285830
],
58295831
[with_readline=readline]
58305832
)
58315833

5834+
dnl gh-105323: Need to handle the macOS editline as an alias of readline.
5835+
AS_VAR_IF([with_readline], [apple], [
5836+
AS_CASE([$ac_sys_system/$ac_sys_release],
5837+
[Darwin/*], [AC_DEFINE([WITH_APPLE_READLINE]) with_readline=readline],
5838+
[])]
5839+
)
5840+
58325841
AS_VAR_IF([with_readline], [readline], [
58335842
PKG_CHECK_MODULES([LIBREADLINE], [readline], [
58345843
LIBREADLINE=readline

pyconfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,6 +1791,9 @@
17911791
/* Define if WINDOW in curses.h offers a field _flags. */
17921792
#undef WINDOW_HAS_FLAGS
17931793

1794+
/* Define to build the readline module agains apple builtin readline. */
1795+
#undef WITH_APPLE_READLINE
1796+
17941797
/* Define if you want build the _decimal module using a coroutine-local rather
17951798
than a thread-local context */
17961799
#undef WITH_DECIMAL_CONTEXTVAR

0 commit comments

Comments
 (0)