SyntaxError when pasting multiple lines in Python

Viewed 969

I'm having trouble copy-pasting code in Python. Say I have the following code I want to paste into a Python interpreter:

string_one = "Help"
string_two = "Me"

Locally, running 3.8.5 on a Mac OSX 10.15.7, if I paste that code, I get SyntaxError: multiple statements found while compiling a single statement.

However, if I ssh into another machine, open up Python (3.7.4), and paste those two lines, I get no error. Also, when I paste those two lines into a Python 2.7.16 shell, I get no error. What could possibly be the problem here?

Python 3 (problem shell) enter image description here

Python 2 (non-problem shell) enter image description here

1 Answers

It seems that there is a bug in readline (which is used by Homebrew to install python)

Short answer:

echo "set enable-bracketed-paste off" >> ~/.inputrc

Long answer: https://github.com/Homebrew/homebrew-core/issues/68193


(This was erroneously edited into the question; I have rolled back that edit, and am pasting the solution as an actual answer instead, and tagging as Community Wiki.)

Related