Skip to content

Commit 501939c

Browse files
authored
pythongh-105323: Update readline module to detect apple editline variant (pythongh-108665)
1 parent db0a258 commit 501939c

File tree

5 files changed

+38
-3
lines changed

5 files changed

+38
-3
lines changed

Doc/using/configure.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -758,11 +758,12 @@ Libraries options
758758

759759
.. versionadded:: 3.3
760760

761-
.. cmdoption:: --with-readline=editline
761+
.. cmdoption:: --with-readline=readline|editline
762762

763-
Use ``editline`` library for backend of the :mod:`readline` module.
763+
Designate a backend library for the :mod:`readline` module.
764764

765-
Define the ``WITH_EDITLINE`` macro.
765+
* readline: Use readline as the backend.
766+
* editline: Use editline as the backend.
766767

767768
.. versionadded:: 3.10
768769

Modules/readline.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,8 @@ on_hook(PyObject *func)
10181018
static int
10191019
#if defined(_RL_FUNCTION_TYPEDEF)
10201020
on_startup_hook(void)
1021+
#elif defined(WITH_APPLE_EDITLINE)
1022+
on_startup_hook(const char *Py_UNUSED(text), int Py_UNUSED(state))
10211023
#else
10221024
on_startup_hook(void)
10231025
#endif
@@ -1033,6 +1035,8 @@ on_startup_hook(void)
10331035
static int
10341036
#if defined(_RL_FUNCTION_TYPEDEF)
10351037
on_pre_input_hook(void)
1038+
#elif defined(WITH_APPLE_EDITLINE)
1039+
on_pre_input_hook(const char *Py_UNUSED(text), int Py_UNUSED(state))
10361040
#else
10371041
on_pre_input_hook(void)
10381042
#endif

configure

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

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

58345834
AH_TEMPLATE([WITH_EDITLINE], [Define to build the readline module against libedit.])
5835+
AH_TEMPLATE([WITH_APPLE_EDITLINE], [Define to build the readline module against Apple BSD editline.])
58355836

58365837
AC_ARG_WITH(
58375838
[readline],
@@ -5848,6 +5849,15 @@ AC_ARG_WITH(
58485849
[with_readline=readline]
58495850
)
58505851

5852+
# gh-105323: Need to handle the macOS editline as an alias of readline.
5853+
AS_CASE([$ac_sys_system/$ac_sys_release],
5854+
[Darwin/*], [AC_CHECK_TYPE([Function],
5855+
[AC_DEFINE([WITH_APPLE_EDITLINE])],
5856+
[],
5857+
[@%:@include <readline/readline.h>])],
5858+
[]
5859+
)
5860+
58515861
AS_VAR_IF([with_readline], [readline], [
58525862
PKG_CHECK_MODULES([LIBREADLINE], [readline], [
58535863
LIBREADLINE=readline

pyconfig.h.in

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

1791+
/* Define to build the readline module against Apple BSD editline. */
1792+
#undef WITH_APPLE_EDITLINE
1793+
17911794
/* Define if you want build the _decimal module using a coroutine-local rather
17921795
than a thread-local context */
17931796
#undef WITH_DECIMAL_CONTEXTVAR

0 commit comments

Comments
 (0)