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

disable python shell integration for wsl #24446

Merged
merged 2 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion python_files/pythonrc.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import platform
import sys

if sys.platform != "win32":
import readline

original_ps1 = ">>> "
use_shell_integration = sys.version_info < (3, 13)
is_wsl = "microsoft-standard-WSL" in platform.release()


class REPLHooks:
Expand Down Expand Up @@ -73,5 +75,5 @@ def __str__(self):
return result


if sys.platform != "win32" and use_shell_integration:
if sys.platform != "win32" and (not is_wsl) and use_shell_integration:
sys.ps1 = PS1()
7 changes: 5 additions & 2 deletions python_files/tests/test_shell_integration.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import importlib
import platform
import sys
from unittest.mock import Mock

import pythonrc

is_wsl = "microsoft-standard-WSL" in platform.release()


def test_decoration_success():
importlib.reload(pythonrc)
ps1 = pythonrc.PS1()

ps1.hooks.failure_flag = False
result = str(ps1)
if sys.platform != "win32":
if sys.platform != "win32" and (not is_wsl):
assert (
result
== "\x1b]633;E;None\x07\x1b]633;D;0\x07\x1b]633;A\x07>>> \x1b]633;B\x07\x1b]633;C\x07"
Expand All @@ -26,7 +29,7 @@ def test_decoration_failure():

ps1.hooks.failure_flag = True
result = str(ps1)
if sys.platform != "win32":
if sys.platform != "win32" and (not is_wsl):
assert (
result
== "\x1b]633;E;None\x07\x1b]633;D;1\x07\x1b]633;A\x07>>> \x1b]633;B\x07\x1b]633;C\x07"
Expand Down
Loading