diff --git a/python_files/pythonrc.py b/python_files/pythonrc.py index 5791bb3967c0..13f374e023b8 100644 --- a/python_files/pythonrc.py +++ b/python_files/pythonrc.py @@ -1,3 +1,4 @@ +import platform import sys if sys.platform != "win32": @@ -5,6 +6,7 @@ original_ps1 = ">>> " use_shell_integration = sys.version_info < (3, 13) +is_wsl = "microsoft-standard-WSL" in platform.release() class REPLHooks: @@ -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() diff --git a/python_files/tests/test_shell_integration.py b/python_files/tests/test_shell_integration.py index ea7ea4099bb2..a7dfc2ff1a8f 100644 --- a/python_files/tests/test_shell_integration.py +++ b/python_files/tests/test_shell_integration.py @@ -1,9 +1,12 @@ 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) @@ -11,7 +14,7 @@ def test_decoration_success(): 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" @@ -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"