diff options
author | 2021-02-15 15:47:52 -0800 | |
---|---|---|
committer | 2021-02-15 15:47:52 -0800 | |
commit | f9d7c12b6c7ab978cb6c61a666bc06dd3fec9b3e (patch) | |
tree | daf0cea3f3f1c57242e852d3db15342fb1521acd | |
parent | Add a warning block around the get_referrers() documentation (GH-24511) (diff) | |
download | cpython-3.8.tar.gz cpython-3.8.tar.bz2 cpython-3.8.zip |
bpo-42819, readline: Disable bracketed paste (GH-24108)3.8
(cherry picked from commit 755f3c1521b422bc2177013d289f5439975fdc4f)
Co-authored-by: Dustin Rodrigues <dust.rod@gmail.com>
-rw-r--r-- | Misc/ACKS | 1 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Core and Builtins/2021-01-04-23-54-34.bpo-42819.4KO6wU.rst | 8 | ||||
-rw-r--r-- | Modules/readline.c | 23 |
3 files changed, 32 insertions, 0 deletions
diff --git a/Misc/ACKS b/Misc/ACKS index 8ca1f64c9f5..e181c617116 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1415,6 +1415,7 @@ Mark Roddy Kevin Rodgers Sean Rodman Giampaolo Rodola +Dustin Rodrigues Mauro S. M. Rodrigues Elson Rodriguez Adi Roiban diff --git a/Misc/NEWS.d/next/Core and Builtins/2021-01-04-23-54-34.bpo-42819.4KO6wU.rst b/Misc/NEWS.d/next/Core and Builtins/2021-01-04-23-54-34.bpo-42819.4KO6wU.rst new file mode 100644 index 00000000000..d067f0bfa76 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2021-01-04-23-54-34.bpo-42819.4KO6wU.rst @@ -0,0 +1,8 @@ +:mod:`readline`: 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")``. Patch by +Dustin Rodrigues. diff --git a/Modules/readline.c b/Modules/readline.c index 081657fb236..9b30d597c84 100644 --- a/Modules/readline.c +++ b/Modules/readline.c @@ -141,6 +141,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 */ static PyObject * @@ -187,6 +207,7 @@ read_init_file(PyObject *self, PyObject *args) errno = rl_read_init_file(NULL); if (errno) return PyErr_SetFromErrno(PyExc_OSError); + disable_bracketed_paste(); Py_RETURN_NONE; } @@ -1146,6 +1167,8 @@ setup_readline(readlinestate *mod_state) else rl_initialize(); + disable_bracketed_paste(); + RESTORE_LOCALE(saved_locale) } |