Skip to content

Interactive shell doesn't work with readline bracketed paste #76200

Closed

Description

@asmeurer
mannequin
BPO 32019
Nosy @vstinner, @asmeurer, @tirkarthi
Superseder
  • bpo-39820: Bracketed paste mode for REPL: don't execute pasted command before ENTER is pressed explicitly
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-02-15.09:49:01.269>
    created_at = <Date 2017-11-13.23:02:31.953>
    labels = []
    title = "Interactive shell doesn't work with readline bracketed paste"
    updated_at = <Date 2021-02-15.09:49:01.267>
    user = 'https://github.com/asmeurer'

    bugs.python.org fields:

    activity = <Date 2021-02-15.09:49:01.267>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-02-15.09:49:01.269>
    closer = 'vstinner'
    components = []
    creation = <Date 2017-11-13.23:02:31.953>
    creator = 'Aaron.Meurer'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 32019
    keywords = []
    message_count = 2.0
    messages = ['306176', '386990']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'Aaron.Meurer', 'xtreak']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '39820'
    type = None
    url = 'https://bugs.python.org/issue32019'
    versions = []

    Activity

    1. asmeurer commented on Nov 13, 2017

      asmeurermannequin
      MannequinAuthor

      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.

    2. vstinner commented on Feb 15, 2021

      @vstinner
      Member

      I mark this issue as a duplicate of bpo-39820.

    3. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      No labels
      No labels

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions