This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Interactive shell doesn't work with readline bracketed paste
Type: Stage: resolved
Components: Versions:
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Bracketed paste mode for REPL: don't execute pasted command before ENTER is pressed explicitly
View: 39820
Assigned To: Nosy List: Aaron.Meurer, vstinner, xtreak
Priority: normal Keywords:

Created on 2017-11-13 23:02 by Aaron.Meurer, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg306176 - (view) Author: Aaron Meurer (Aaron.Meurer) Date: 2017-11-13 23:02
Here are the steps to reproduce this:

- Compile and link Python against readline version 7.0 or higher.
- Add 

set enable-bracketed-paste on

to your ~/.inputrc

- Start python and paste the following two lines. Make sure to use a terminal emulator that supports bracketed paste (most modern ones do). You'll need to type enter after pasting the lines. 

a = 1
a


You get something like

>>> a = 1
a
  File "<stdin>", line 1
    a

    ^
SyntaxError: multiple statements found while compiling a single statement

It does work, however, if you paste something that has a newline but is a single statement, like

(1, 
2)

Fixing this in the right way might not be so easy, due to the way that compile('single') is over-engineered. A simple fix would be to disable bracketed paste in the Python shell. 

I tested this with Python 3.6.3. I was not able to get the git master to compile, so I couldn't test it there.
msg386990 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-02-15 09:49
I mark this issue as a duplicate of bpo-39820.
History
Date User Action Args
2022-04-11 14:58:54adminsetgithub: 76200
2021-02-15 09:49:01vstinnersetstatus: open -> closed

superseder: Bracketed paste mode for REPL: don't execute pasted command before ENTER is pressed explicitly

nosy: + vstinner
messages: + msg386990
resolution: duplicate
stage: resolved
2018-09-20 13:24:02xtreaksetnosy: + xtreak
2017-11-13 23:02:31Aaron.Meurercreate