pythonpython-3.13

Python 3.13.1 Breaks Indentation When Pasting Code in Terminal


Python 3.13.1 results in unexpected indentation errors when I copy and paste Python code into its windows terminal (as shown in the pic below). This did not happen in Python 3.12.x or earlier.

In windows terminal open python 3.13.1, and 3.12.8 separately, and paste the below code for example

def fun1():
  if 5 > 3:
    return 'a'
  return 0

and hit enter.. You should get the below for 3.13.1 enter image description here and below for 3.12.8 (and versions before)... enter image description here

(I pasted using a simple right click in windows terminal, and check multiple times the steps are same)

has anyone faced this issue, and how did you fix this


Solution

  • Press F3 before pasting (new in Python 3.13). Press F3 again when done pasting.

    See What's New in Python 3.13: New Features - A better interactive interpreter.