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 11 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 @@ -615,11 +615,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
14 changes: 12 additions & 2 deletions Modules/readline.c
Original file line number Diff line number Diff line change
Expand Up @@ -1018,10 +1018,16 @@ on_hook(PyObject *func)
static int
#if defined(_RL_FUNCTION_TYPEDEF)
on_startup_hook(void)
{
#elif defined(__APPLE__) && defined(WITH_APPLE_EDITLINE)
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 @@ -1033,10 +1039,14 @@ on_startup_hook(void)
static int
#if defined(_RL_FUNCTION_TYPEDEF)
on_pre_input_hook(void)
{
#elif defined(__APPLE__) && defined(WITH_APPLE_EDITLINE)
erlend-aasland marked this conversation as resolved.
Show resolved Hide resolved
on_pre_input_hook(const char *Py_UNUSED(text), int Py_UNUSED(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
56 changes: 56 additions & 0 deletions aclocal.m4

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

39 changes: 39 additions & 0 deletions configure

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

3 changes: 3 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,7 +5831,9 @@ AC_ARG_WITH(
[with_readline=readline]
)


AS_VAR_IF([with_readline], [readline], [
AX_CHECK_TYPEDEF(Function, readline/readline.h, [,AC_DEFINE([WITH_APPLE_EDITLINE]),])
Copy link
Member Author

@corona10 corona10 Sep 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure that we have to support for AS_VAR_IF([with_readline], [edit], [...]) case too

PKG_CHECK_MODULES([LIBREADLINE], [readline], [
LIBREADLINE=readline
READLINE_CFLAGS=$LIBREADLINE_CFLAGS
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