Skip to content

Commit

Permalink
pythongh-105323: Update readline module to detect apple editline vari…
Browse files Browse the repository at this point in the history
  • Loading branch information
corona10 authored Sep 29, 2023
1 parent db0a258 commit 501939c
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Doc/using/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -758,11 +758,12 @@ Libraries options

.. versionadded:: 3.3

.. cmdoption:: --with-readline=editline
.. cmdoption:: --with-readline=readline|editline

Use ``editline`` library for backend of the :mod:`readline` module.
Designate a backend library for the :mod:`readline` module.

Define the ``WITH_EDITLINE`` macro.
* readline: Use readline as the backend.
* editline: Use editline as the backend.

.. versionadded:: 3.10

Expand Down
4 changes: 4 additions & 0 deletions Modules/readline.c
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,8 @@ on_hook(PyObject *func)
static int
#if defined(_RL_FUNCTION_TYPEDEF)
on_startup_hook(void)
#elif defined(WITH_APPLE_EDITLINE)
on_startup_hook(const char *Py_UNUSED(text), int Py_UNUSED(state))
#else
on_startup_hook(void)
#endif
Expand All @@ -1033,6 +1035,8 @@ on_startup_hook(void)
static int
#if defined(_RL_FUNCTION_TYPEDEF)
on_pre_input_hook(void)
#elif defined(WITH_APPLE_EDITLINE)
on_pre_input_hook(const char *Py_UNUSED(text), int Py_UNUSED(state))
#else
on_pre_input_hook(void)
#endif
Expand Down
17 changes: 17 additions & 0 deletions configure

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

10 changes: 10 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -5832,6 +5832,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_EDITLINE], [Define to build the readline module against Apple BSD editline.])

AC_ARG_WITH(
[readline],
Expand All @@ -5848,6 +5849,15 @@ AC_ARG_WITH(
[with_readline=readline]
)

# gh-105323: Need to handle the macOS editline as an alias of readline.
AS_CASE([$ac_sys_system/$ac_sys_release],
[Darwin/*], [AC_CHECK_TYPE([Function],
[AC_DEFINE([WITH_APPLE_EDITLINE])],
[],
[@%:@include <readline/readline.h>])],
[]
)

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 @@ -1788,6 +1788,9 @@
/* Define if WINDOW in curses.h offers a field _flags. */
#undef WINDOW_HAS_FLAGS

/* Define to build the readline module against Apple BSD editline. */
#undef WITH_APPLE_EDITLINE

/* 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 501939c

Please sign in to comment.