Skip to content

Python3.13 All functions fail to send: IndentationError: unexpected indent #24256

Closed

Description

Discussed in #24222

Originally posted by ddxv October 2, 2024
I recently fired up Python3.13rc2 but quickly found that any lines I send to the terminal do not work, specifically anything with additional line breaks or with indentation.

The new REPL, as I'm sure you know, autoindents for users. So it appears I'm getting a new indent for each line + the existing indent, causing a deeper and deeper indent even on a flat function. As you can see in the screenshot:
image

This inevitably leads to: IndentationError: unexpected indent

I'm opening a discussion because I don't see others mentioning this for Python 3.13, so I was not sure if this is actually a bug or something unique to my settings?

If others are encountering this, happy to turn this into a ticket.

Activity

  1. AlexNaglich commented on Oct 14, 2024

    @AlexNaglich

    I am experiencing the same.

    Version: 1.94.2 (system setup)
    Commit: 384ff7382de624fb94dbaf6da11977bba1ecd427
    Date: 2024-10-09T16:08:44.566Z
    Electron: 30.5.1
    ElectronBuildId: 10262041
    Chromium: 124.0.6367.243
    Node.js: 20.16.0
    V8: 12.4.254.20-electron.0
    OS: Windows_NT x64 10.0.26100
    python: 3.13.0

  2. MMateo1120 commented on Oct 14, 2024

    @MMateo1120

    Same behaviour and error, only happens with python 3.13, 3.12 works fine.

  3. anthonykim1 commented on Oct 17, 2024

    @anthonykim1

    Thanks for the bug report! We investigate issues in order based on priority and severity, which includes the impact it has on your ability to use the extension to do productive work, and the number of people affected. If other users come forward and leave a comment demonstrating they are seeing/reproducing the problem then we will raise this issue's priority. Thanks for understanding and the patience!

    Please go ahead and upvote this meanwhile so that we can further acknowledge the severity.

  4. AlexNaglich commented on Oct 17, 2024

    @AlexNaglich

    Regarding severity, it greatly inhibited my ability to do work. Testing individual blocks of code is no longer a viable option for me. I cannot copy paste, I cannot shift+enter, I cannot right click and run in interactive window... I have to modify the python code, then to non-interactively test I run the entire program that calls the python. Dramatic decrease in productivity as a result of tedious testing and debugging.

  5. teuncm commented on Oct 18, 2024

    @teuncm

    For me and students of our classes the impact is also huge. We teach the first steps of Python programming by letting them run blocks of code using shift+enter, but with the new behavior this is no longer an option at all.

  6. cbrnr commented on Oct 24, 2024

    @cbrnr

    I just wanted to add that this also severely impacts how I use Python 3.13 in Visual Studio Code. For those looking for a workaround (other than downgrading Python to ≤ 3.12 or setting the env variable PYTHON_BASIC_REPL=1, which are both not good options), is to use the "Native REPL" (enable in the settings).

  7. cbrnr commented on Oct 24, 2024

    @cbrnr

    BTW, just to let Windows users know that this currently does not work in Windows Terminal either, see python/cpython#124119.

  8. masai2018 commented on Oct 29, 2024

    @masai2018

    I updated VS Code to the most updated version (1.95.0) but still have the same error with Python 3.13 on Windows and Mac OS.

  9. anthonykim1 commented on Oct 29, 2024

    @anthonykim1

    Thanks Clemens Brunner (@cbrnr) for

    (other than downgrading Python to ≤ 3.12 or setting the env variable PYTHON_BASIC_REPL=1, which are both not good options), is to use the "Native REPL" (enable in the settings).

    Thanks everyone for the feedback here. Team is actively looking into resolving this, but please try out the "Native REPL" setting to send code and execute in Native REPL instead of terminal meanwhile.

  10. 36 remaining items

  11. aelb66 commented on Mar 19, 2025

    @aelb66

    Having the same indentation error issue

  12. CannotBii commented on Mar 26, 2025

    @CannotBii

    Hi Karthik Nadig (@karthiknadig) , May i know if this issue was resolved?

  13. karthiknadig commented on Mar 27, 2025

    @karthiknadig
    MemberAuthor

    CannotBii yes. But note that there is a issue on python itself that isn't python/cpython#124096

  14. wjandrea commented on May 18, 2025

    @wjandrea

    I have this error and it's a really boring!

    *it's really annoying

    «ennuyeux» a deux traductions en anglais qui sont totalement différentes :)

  15. GS-R1 commented on Jun 9, 2025

    @GS-R1

    I'm having the same indentation issue.

  16. we684123 commented on Jun 13, 2025

    @we684123

    I don't know what happened, but this version now allows Python 3.13 to run in the terminal without showing the 'unexpected indent' error.

    版本: 1.101.0 (system setup)
    認可: dfaf44141ea9deb3b4096f7cd6d24e00c147a4b1
    日期: 2025-06-11T15:00:50.123Z
    Electron: 35.5.1
    ElectronBuildId: 11727614
    Chromium: 134.0.6998.205
    Node.js: 22.15.1
    V8: 13.4.114.21-electron.0
    OS: Windows_NT x64 10.0.26100

    Image

  17. marcoaurelioguerrap commented on Jun 24, 2025

    @marcoaurelioguerrap

    I'm having issues with this error as well. This is how I develop code, It will greatly impact on my performance. I'm using an older python version beause of this

  18. anthonykim1 commented on Jun 27, 2025

    @anthonykim1

    I don't know what happened, but this version now allows Python 3.13 to run in the terminal without showing the 'unexpected indent' error.

    I think its combination of #24401 python/cpython#124119 and python/cpython#133457

    Hi folks, I've resolved #25164 which would effectively bring you to the REPL that you are used to using, and you won't need to press extra enter in the terminal to run your command, or experience further indentation issues.

    Please give a pre-release version of Python extension a try on VS Code insiders.

    Thanks aton and let me know if something comes up.

    Also give https://code.visualstudio.com/updates/v1_101#_language-server-based-terminal-suggest a try :)
    We've brought the language server completions to REPL in terminal, which would make the REPL experience lot more positive and enjoyable.

  19. Tyler-widd commented on Jun 27, 2025

    @Tyler-widd
  20. Tyler-widd commented on Jul 20, 2025

    @Tyler-widd

    It seems it was fixed but now is no longer working again...

  21. marcoaurelioguerrap commented on Jul 20, 2025

    @marcoaurelioguerrap

    I don't know if this is helpfull or viable but after installing oh-my-posh it is working again.

  22. Tyler-widd commented on Jul 20, 2025

    @Tyler-widd

    Anthony Kim (@anthonykim1) does this mean it works on the release version?

  23. Tyler-widd commented on Jul 24, 2025

    @Tyler-widd

    Seems like the release version is now breaking as well again

  24. anthonykim1 commented on Jul 24, 2025

    @anthonykim1

    HI folks, sorry for the regression. I've resolved this again here #25296 and this should've been out on the latest point release.

    Can people update to latest release (2025.10.1) , or pre-release and see?

    Make sure to restart extension and run command "Python Clear Cache and Reload"

  25. Tyler-widd commented on Jul 28, 2025

    @Tyler-widd

    I did as you said, hit ctrl+p and found 'Python Clear Cache and Reload'

    I still run into issue
    Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-replbugIssue identified by VS Code Team member as probable bugverification-neededVerification of issue is requestedverifiedVerification succeeded

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions