gh-117845: Detect libedit hook function signature in configure (#117870)

Older libedit versions (like Apple's) use a different type signature
for rl_startup_hook and rl_pre_input_hook. Add a configure check to
determine which signature is accepted by introducing the
Py_RL_STARTUP_HOOK_TAKES_ARGS macro in pyconfig.h.
This commit is contained in:
Joshua Root 2024-04-17 19:26:10 +10:00 committed by GitHub
parent f74e51229c
commit 8515fd79fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 71 additions and 2 deletions

View file

@ -1041,7 +1041,7 @@ on_hook(PyObject *func)
}
static int
#if defined(_RL_FUNCTION_TYPEDEF)
#if defined(_RL_FUNCTION_TYPEDEF) || !defined(Py_RL_STARTUP_HOOK_TAKES_ARGS)
on_startup_hook(void)
#else
on_startup_hook(const char *Py_UNUSED(text), int Py_UNUSED(state))
@ -1061,7 +1061,7 @@ on_startup_hook(const char *Py_UNUSED(text), int Py_UNUSED(state))
#ifdef HAVE_RL_PRE_INPUT_HOOK
static int
#if defined(_RL_FUNCTION_TYPEDEF)
#if defined(_RL_FUNCTION_TYPEDEF) || !defined(Py_RL_STARTUP_HOOK_TAKES_ARGS)
on_pre_input_hook(void)
#else
on_pre_input_hook(const char *Py_UNUSED(text), int Py_UNUSED(state))