Skip to content
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

gh-105323: Update readline module to detect apple editline variant #108665

Merged
merged 19 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from 17 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
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.
Desinate a backend library of the :mod:`readline` module.
corona10 marked this conversation as resolved.
Show resolved Hide resolved

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)
corona10 marked this conversation as resolved.
Show resolved Hide resolved
#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 @@ -5814,6 +5814,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 @@ -5830,6 +5831,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
Loading