python / cpython

The Python programming language
https://www.python.org/
Other
60.95k stars 29.41k forks source link

Bad indentation after pasting code in interactive interpreter #121400

Open rudyment opened 4 days ago

rudyment commented 4 days ago

Bug report

Bug description:

In the interactive interpreter it is not possible to simply insert function definitions from the clipboard, because each line of the function body is indented compared to the previous one.

If I copy the function definition:

def f(): x = 1 x = 2

to the clipboard and paste it into the interactive interpreter, I get

>>> def f(): ... x = 1 ... x = 2 File "<unknown>", line 3 x = 2 IndentationError: unexpected indent >>>

CPython versions tested on:

3.13

Operating systems tested on:

Windows

JamesParrott commented 4 days ago

I've not been able to reproduce this, in 3.13.0a5 from Bash, CMD or Powershell, on Windows 11.

Please could you supply more details, including the exact contents to copy from, e.g. in a Markdown literal code block (enclosed in a pair of triple back-ticks)?

Eclips4 commented 4 days ago

I've able to reproduce it on current main (Windows 10).