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

Properly differentiate Windows, Linux, and WSL in pythonrc.py script #23829

Closed
vladjohnson opened this issue Jul 16, 2024 · 13 comments · Fixed by #24446
Closed

Properly differentiate Windows, Linux, and WSL in pythonrc.py script #23829

vladjohnson opened this issue Jul 16, 2024 · 13 comments · Fixed by #24446
Assignees
Labels
area-repl area-terminal bug Issue identified by VS Code Team member as probable bug verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@vladjohnson
Copy link

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: Version: 1.91.0 (system setup)
  • OS Version: Windows_NT x64 10.0.19045

Hi there, I am having issues with VS Code custom sequences making their way into the Python shell. For instance: ]633;E;quit()]633;D;0]633;A>>> ]633;B]633;C. I've tried disabling the shell integration, but it does not work. Please help!
Screenshot 2024-07-16 171128

Steps to Reproduce:

  1. Open a .py file and run python file using the "Run Python File" button on the right upper corner.
  2. In the opened terminal, type python or python3.
@vscodenpa
Copy link

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.91.1. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

@vladjohnson
Copy link
Author

vladjohnson commented Jul 16, 2024

Problem still exists. Thank you!

@Tyriar Tyriar transferred this issue from microsoft/vscode Jul 17, 2024
@Tyriar Tyriar assigned anthonykim1 and unassigned Tyriar Jul 17, 2024
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Jul 17, 2024
@Tyriar
Copy link
Member

Tyriar commented Jul 17, 2024

@anthonykim1 is this stuff not behind an opt-in setting atm?

@vladjohnson
Copy link
Author

@anthonykim1 @Tyriar thank you so much for helping out!

@anthonykim1
Copy link

anthonykim1 commented Jul 25, 2024

Thanks for filing the issue @vladjohnson

@Tyriar Yeap, this is not behind a setting atm.

I'm bit surprised about this because we don't enable this for windows folks at all.
We use

if sys.platform != "win32":
    sys.ps1 = PS1()

to filter out windows folks and only attach such sequence for non-windows users who use Terminal Python REPL.

Now I am wondering if "win32" is not sufficient.

Can you please

import sys

and print

sys.platform

and let me know of the value?

I'm guessing we may have to handle it better for WSL.

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Jul 25, 2024
@vladjohnson
Copy link
Author

@anthonykim1 sure thing! The platform value is 'linux'. I am running Ubuntu 20.04 LTS in WSL 2. Thanks!

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Jul 29, 2024
@anthonykim1
Copy link

@vladjohnson Thanks for this!

So I basically need to be more through than
sys.platform != "window32"
and sort out that user can be in 'linux' environment via Windows.

I'll mark this as bug, and let you know once I have the fix. Thank you

@anthonykim1 anthonykim1 added the bug Issue identified by VS Code Team member as probable bug label Aug 7, 2024
@vladjohnson
Copy link
Author

Thank you! Appreciate it, @anthonykim1

@anthonykim1 anthonykim1 added area-repl area-terminal and removed triage-needed Needs assignment to the proper sub-team labels Aug 8, 2024
@anthonykim1
Copy link

anthonykim1 commented Sep 23, 2024

Hi @vladjohnson
I haven't got a chance to solve the problem itself, we now have a setting to toggle on/off which is related to what you are seeing on the screen.

Its called

python.terminal.shellIntegration.enabled

and you can toggle this off on your settings UI or modify your settings.json starting TOMORROW's pre-release version of the Python extension.

Still planning to fix the root cause like I've mentioned in

So I basically need to be more through than
sys.platform != "window32"
and sort out that user can be in 'linux' environment via Windows.

But perhaps you could utilize the setting beforehand :) - Thanks again for your patience

@anthonykim1 anthonykim1 changed the title Issue with VS Code custom sequences 'OSC 633 ; ... ST' in Python shell for Ubuntu in WSL 2 Properly differentiate Windows, Linux, and WSL in pythonrc.py script Sep 23, 2024
@anthonykim1 anthonykim1 added this to the October 2024 milestone Sep 23, 2024
@vladjohnson
Copy link
Author

Thanks :) Appreciate it, @anthonykim1

@anthonykim1
Copy link

@vladjohnson could you try latest pre-release of Python extension? This should be resolved now

@vladjohnson
Copy link
Author

Thank you! Will try

@anthonykim1 anthonykim1 added the verification-needed Verification of issue is requested label Dec 2, 2024
@anthonykim1
Copy link

Verification steps:

  1. Make sure you are on the latest VS Code insiders & pre-release of Python extension.
  2. With WSL, turn on the setting to opt into "shell integration" under Python setting.
  3. Shift+enter to send command to terminal (make sure you have not enabled 'send to native repl' setting)
  4. Make sure you do not see the escape sequences on your terminal

@rzhao271 rzhao271 added the verified Verification succeeded label Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-repl area-terminal bug Issue identified by VS Code Team member as probable bug verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants