Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Simpler hook check
  • Loading branch information
tonybaloney committed Nov 28, 2023
commit ff038f02379bc99755b74d6b9895d6f8f8a990ec
23 changes: 3 additions & 20 deletions Modules/readline.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,6 @@ readline_clear(PyObject *m)
return 0;
}

/* This undoes any readline configuration done in setup_readline(). */
static void
readline_cleanup(void)
{
rl_startup_hook = NULL;
#ifdef HAVE_RL_PRE_INPUT_HOOK
rl_pre_input_hook = NULL;
#endif
rl_attempted_completion_function = NULL;
}

static int
readline_traverse(PyObject *m, visitproc visit, void *arg)
{
Expand Down Expand Up @@ -1079,18 +1068,12 @@ on_pre_input_hook(void)
{
int r;
PyGILState_STATE gilstate = PyGILState_Ensure();
PyObject* mod = PyState_FindModule(&readlinemodule);
if (mod == NULL) {
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_ImportError, "readline import initialization failure during startup hook");
}
readline_cleanup();
readlinestate *state = get_hook_module_state();
if (state == NULL) {
PyGILState_Release(gilstate);
return -1;
}
Py_INCREF(mod);
r = on_hook(get_readline_state(mod)->pre_input_hook);
Py_DECREF(mod);
r = on_hook(state->pre_input_hook);
PyGILState_Release(gilstate);
return r;
}
Expand Down