Issue #24266: Cancel history search mode with Ctrl+C in Readline 7
diff --git a/Misc/NEWS b/Misc/NEWS
index 3f6ae5d..0ecd9d1 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -61,6 +61,9 @@
Library
-------
+- Issue #24266: Ctrl+C during Readline history search now cancels the search
+ mode when compiled with Readline 7.
+
- Issue #23857: Implement PEP 493, adding a Python-2-only ssl module API and
environment variable to configure the default handling of SSL/TLS certificates
for HTTPS connections.
diff --git a/Modules/readline.c b/Modules/readline.c
index 1e98ffb..4aef879 100644
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -1024,6 +1024,9 @@
#endif
if (s < 0) {
rl_free_line_state();
+#if defined(RL_READLINE_VERSION) && RL_READLINE_VERSION >= 0x0700
+ rl_callback_sigcleanup();
+#endif
rl_cleanup_after_signal();
rl_callback_handler_remove();
*signal = 1;