Skip to content

Commit a2b007c

Browse files
authored
disable python shell integration for wsl (#24446)
Resolves: #23829 From testing: ![Screenshot 2024-11-14 at 11 54 44 PM](https://github.com/user-attachments/assets/18bb29a8-7fca-4989-b4e9-5796d9632151)
1 parent 29d4f35 commit a2b007c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

python_files/pythonrc.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import platform
12
import sys
23

34
if sys.platform != "win32":
45
import readline
56

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

911

1012
class REPLHooks:
@@ -73,5 +75,5 @@ def __str__(self):
7375
return result
7476

7577

76-
if sys.platform != "win32" and use_shell_integration:
78+
if sys.platform != "win32" and (not is_wsl) and use_shell_integration:
7779
sys.ps1 = PS1()

python_files/tests/test_shell_integration.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
import importlib
2+
import platform
23
import sys
34
from unittest.mock import Mock
45

56
import pythonrc
67

8+
is_wsl = "microsoft-standard-WSL" in platform.release()
9+
710

811
def test_decoration_success():
912
importlib.reload(pythonrc)
1013
ps1 = pythonrc.PS1()
1114

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

2730
ps1.hooks.failure_flag = True
2831
result = str(ps1)
29-
if sys.platform != "win32":
32+
if sys.platform != "win32" and (not is_wsl):
3033
assert (
3134
result
3235
== "\x1b]633;E;None\x07\x1b]633;D;1\x07\x1b]633;A\x07>>> \x1b]633;B\x07\x1b]633;C\x07"

0 commit comments

Comments
 (0)