Skip to content
Snippets Groups Projects
Unverified Commit 85fd9f4e authored by Miss Islington (bot)'s avatar Miss Islington (bot) Committed by GitHub
Browse files

bpo-42819, readline: Disable bracketed paste (GH-24108) (GH-24545)


(cherry picked from commit 755f3c15)

Co-authored-by: default avatarDustin Rodrigues <dust.rod@gmail.com>

Co-authored-by: default avatarDustin Rodrigues <dust.rod@gmail.com>
parent 9cc70bc2
No related branches found
No related tags found
No related merge requests found
...@@ -1444,6 +1444,7 @@ Mark Roddy ...@@ -1444,6 +1444,7 @@ Mark Roddy
Kevin Rodgers Kevin Rodgers
Sean Rodman Sean Rodman
Giampaolo Rodola Giampaolo Rodola
Dustin Rodrigues
Mauro S. M. Rodrigues Mauro S. M. Rodrigues
Elson Rodriguez Elson Rodriguez
Adi Roiban Adi Roiban
......
: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.
...@@ -146,6 +146,26 @@ decode(const char *s) ...@@ -146,6 +146,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 */ /* Exported function to send one line to readline's init file parser */
static PyObject * static PyObject *
...@@ -192,6 +212,7 @@ read_init_file(PyObject *self, PyObject *args) ...@@ -192,6 +212,7 @@ read_init_file(PyObject *self, PyObject *args)
errno = rl_read_init_file(NULL); errno = rl_read_init_file(NULL);
if (errno) if (errno)
return PyErr_SetFromErrno(PyExc_OSError); return PyErr_SetFromErrno(PyExc_OSError);
disable_bracketed_paste();
Py_RETURN_NONE; Py_RETURN_NONE;
} }
...@@ -1152,6 +1173,8 @@ setup_readline(readlinestate *mod_state) ...@@ -1152,6 +1173,8 @@ setup_readline(readlinestate *mod_state)
else else
rl_initialize(); rl_initialize();
disable_bracketed_paste();
RESTORE_LOCALE(saved_locale) RESTORE_LOCALE(saved_locale)
return 0; return 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment