summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorDustin Rodrigues <dust.rod@gmail.com>2021-02-15 23:28:24 (GMT)
committerGitHub <noreply@github.com>2021-02-15 23:28:24 (GMT)
commit755f3c1521b422bc2177013d289f5439975fdc4f (patch)
treeb5c707af3d3442087470c94ff9a01ff171b55969 /Modules
parent813db24f7c2c536d587d1832c3c52b44fa9e242e (diff)
downloadcpython-755f3c1521b422bc2177013d289f5439975fdc4f.zip
cpython-755f3c1521b422bc2177013d289f5439975fdc4f.tar.gz
cpython-755f3c1521b422bc2177013d289f5439975fdc4f.tar.bz2
bpo-42819, readline: Disable bracketed paste (GH-24108)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/readline.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/Modules/readline.c b/Modules/readline.c
index c900e07..c79d22f 100644
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -156,6 +156,26 @@ decode(const char *s)
}
+/*
+Explicitly disable bracketed paste in the interactive interpreter, even if it's
+set in the inputrc, is enabled by default (eg GNU Readline 8.1), or a user calls
+readline.read_init_file(). The Python REPL has not implemented bracketed
+paste support. Also, bracketed mode writes the "\x1b[?2004h" escape sequence
+into stdout which causes test failures in applications that don't support it.
+It can still be explicitly enabled by calling readline.parse_and_bind("set
+enable-bracketed-paste on"). See bpo-42819 for more details.
+
+This should be removed if bracketed paste mode is implemented (bpo-39820).
+*/
+
+static void
+disable_bracketed_paste(void)
+{
+ if (!using_libedit_emulation) {
+ rl_variable_bind ("enable-bracketed-paste", "off");
+ }
+}
+
/* Exported function to send one line to readline's init file parser */
/*[clinic input]
@@ -217,6 +237,7 @@ readline_read_init_file_impl(PyObject *module, PyObject *filename_obj)
errno = rl_read_init_file(NULL);
if (errno)
return PyErr_SetFromErrno(PyExc_OSError);
+ disable_bracketed_paste();
Py_RETURN_NONE;
}
@@ -1267,6 +1288,8 @@ setup_readline(readlinestate *mod_state)
else
rl_initialize();
+ disable_bracketed_paste();
+
RESTORE_LOCALE(saved_locale)
return 0;
}