-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
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
Pasting a function definition does not work in 3.13 REPL with Windows Terminal #124096
Comments
The code you show looks fine to me. Is this what you see in 3.13? |
Thank you for the additional clear info. Closing as duplicate. |
This is not a duplicate. It's a Windows-specific issue that WinAPI requires a console application to set their input handle with Even if it is set, the default Windows command prompt, at least on 21H2 LTSC, does not support bracketed-paste. A modern terminal emulator like your Windows Terminal is required for this feature. We need to figure out a way to make an educated guess at user's terminal and turn off the autoindentation if necessary. PYREPL is atm only scanning virtual key codes under Windows, once the console is configured as a virtual terminal, all the keys will be sent in VT sequences. PR: #124119 |
oh, you are right |
I am using VS Code on Windows, and extra indentations are added when I shift+enter my code to run in the terminal. Also, even if I just copy the code into the terminal extra indentations are added. Any solution to the problem so far? The problem seems similar to microsoft/vscode-python#24256 where it was solved for some by the pre-lease version of python extension for vs code, but still exist for me on Windows. Uninstalled every extension but python's: I am using the pre-lease version: the python version of 3.13.0 64-bit: Started a new window, a brand new py file but after shift+enter, the same behaviour is found as before: If i ctrl c ctrl v the code into the terminal, extra indents are added just by the copying of the code into the terminal: |
Adding to @MMateo1120 folks are also able to repro this outside of VS Code terminal (in external terminal) where indentations breaks like the image above. |
I use Linux and vim, opening a terminal to execute python with . The same indentation error happens to me. I find no way to send "bracketed code" to the terminal. Even pasting a block of code doesn't work. The only workaround, other than using python 3.12, that seems to work for me is the following.
into this:
|
I have the same issue with Python 3.13. and I tried with Notepad, Notepad++, Visualstudio. I sent a message to Python Help and I got an answer that Making it work without F3 on Windows is work in progress, tracked here: #124096" However for me even the F3 on Windows not help, as not pasting anything to the terminal. Is there any other way to use Python on Windows like with a Virtual Machine or with any other application? The code: import pandas as pd
import requests
import os
# Load the input file
input_file = 'companies.csv'
df = pd.read_csv(input_file)
# Your SerpAPI key
SERPAPI_KEY = 'INSERT Your SERPAPI_KEY_HERE'
base_url = 'https://serpapi.com/search'
# Create a list to hold results
results = []
# Loop through each company name and fetch website
for company in df['Company Name']:
params = {
'api_key': SERPAPI_KEY,
'engine': 'google',
'q': company,
'hl': 'en',
'gl': 'us'
}
response = requests.get(base_url, params=params)
data = response.json()
# Get the first organic result link
if 'organic_results' in data and len(data['organic_results']) > 0:
website = data['organic_results'][0].get('link')
results.append({'Company Name': company, 'Website': website})
else:
results.append({'Company Name': company, 'Website': None})
# Create a DataFrame and save to CSV
results_df = pd.DataFrame(results)
results_df.to_csv('company_websites.csv', index=False) |
Hi, I solved the problem by writing the code into Visualstudio and run in cmd with the At the beginning of the code I wrote and the end print("Finished processing for company:", company) I run it, but got an indentation error on line 17 regarding the params inside the for loop. I used 4 white spaces to fix it and another 4 spaces to fix lines under: Then I saved it in Visualstudio and run it again in cmd with and voila it run successfully and did not try to copy and paste into Python terminal. So writing a code in Visualbasic and then saving it, and then running with cmd looks like a solution so far. |
To support virtual terminal mode in Windows PYREPL, we need a scanner to read over the supported escaped VT sequences. Windows REPL input was using virtual key mode, which does not support terminal escape sequences. This patch calls `SetConsoleMode` properly when initializing and send sequences to enable bracketed-paste modes to support verbatim copy-and-paste. Signed-off-by: y5c4l3 <y5c4l3@proton.me> Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com> Co-authored-by: Dustin L. Howett <dustin@howett.net> Co-authored-by: wheeheee <104880306+wheeheee@users.noreply.github.com>
Bug report
Bug description:
I use Python downloaded from python.org without using a graphical environment such as IPython. Instead, I use the Windows Terminal with the REPL built into python.exe. In 3.12.6, I can paste a function definition copied from a text editor directly into the REPL and everything works fine. In 3.13.rc2 this does not work; the indentation is all messed up and I get an IndentationError.
CPython versions tested on:
3.12, 3.13
Operating systems tested on:
Windows
Linked PRs
The text was updated successfully, but these errors were encountered: