Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Programmatically sending indented code to 3.13 REPL causes indentation error #126449

Open
anthonykim1 opened this issue Nov 5, 2024 · 5 comments
Labels
3.13 bugs and security fixes 3.14 new features, bugs and security fixes topic-repl Related to the interactive shell

Comments

@anthonykim1
Copy link

anthonykim1 commented Nov 5, 2024

Bug report

Bug description:

Bug Report


Bug Description

Hello, I am working on improving REPL and Terminal experience for people using VS Code Python, and we have been experiencing the indentation issue similar to one you would see in #124096.

I do realize there are indentation error issue mentioned such as one above, but I wasn't sure if it is rooted from same problem since the one in #124096 is Windows, and I am seeing it on MacOS ARM (tested on zsh, xterm.js since we are talking about terminal in VS Code).

From what I've seen, the indentation gets messed up when we programmatically send a indented string into the 3.13 REPL launched from the VS Code Terminal. If I were to send the exact same Python code to 3.13 and to non-3.13(such as 3.9) REPL programmatically, it will lead to two different result:

  • One from Python3.9 (or non-3.13) will be fine, but code sent to 3.13 REPL will suffer from additional indentation as you see below:
Screenshot 2024-11-05 at 8 00 12 AM

What I found surprising during my investigation is that copy-pasting the exact same code, works fine when I manually copy and paste to external Terminal (Both outside of VS Code and also inside VS Code Terminal)

I'm suspecting that there are either:

  1. Magical copy-paste detection mechanism built into 3.13 REPL (such via custom sequences or some environment variable) that VS Code is missing to do.
  2. Something in the new auto-identation that does not accept programmatic send of text to REPL that does not respect pre-idented Python code to be run.

Another issue related to 3.13 REPL in VS Code: #126131

Thanks in advance for your help and care.

/cc @brettcannon @pablogsal @Tyriar

CPython versions tested on:

3.13

Operating systems tested on:

macOS

@anthonykim1 anthonykim1 added the type-bug An unexpected behavior, bug, or error label Nov 5, 2024
@ZeroIntensity ZeroIntensity added 3.13 bugs and security fixes 3.14 new features, bugs and security fixes topic-repl Related to the interactive shell labels Nov 5, 2024
@brettcannon
Copy link
Member

And /cc @ambv

@ambv
Copy link
Contributor

ambv commented Nov 5, 2024

@anthonykim1, you can programatically paste code using bracketed pasting, in which case additional indentation won't be inserted by the REPL.

@ambv ambv removed the type-bug An unexpected behavior, bug, or error label Nov 5, 2024
@Tyriar
Copy link

Tyriar commented Nov 5, 2024

@ambv that sounds like a workaround that might work for us, but the content is not pasted and you shouldn't need to do that (this is a bug).

@ambv
Copy link
Contributor

ambv commented Nov 5, 2024

The REPL accepts interactive input and automatically indents. How is that a bug? Do you have a suggestion how a TTY application is supposed to automatically discover "programmatic input"? AFAICT this is what bracketed paste is for, it's literally for pre-formatted input.

@Tyriar
Copy link

Tyriar commented Nov 6, 2024

@ambv oh sorry I thought this was #126131 😅 you're right. Bracketed paste mode is the right fix here on our end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes 3.14 new features, bugs and security fixes topic-repl Related to the interactive shell
Projects
None yet
Development

No branches or pull requests

5 participants