Skip to content

Commit 3e430e1

Browse files
committed
Convert sys.ps1 to a string to work-around non-str sys.ps1 from vscode (fixes #1041)
1 parent c07b6f3 commit 3e430e1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

bpython/repl.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,11 +535,17 @@ def __init__(self, interp: Interpreter, config: Config):
535535

536536
@property
537537
def ps1(self) -> str:
538-
return cast(str, getattr(sys, "ps1", ">>> "))
538+
if hasattr(sys, "ps1"):
539+
# noop in most cases, but at least vscode injects a non-str ps1
540+
# see #1041
541+
return str(sys.ps1)
542+
return ">>> "
539543

540544
@property
541545
def ps2(self) -> str:
542-
return cast(str, getattr(sys, "ps2", "... "))
546+
if hasattr(sys, "ps2"):
547+
return str(sys.ps2)
548+
return ">>> "
543549

544550
def startup(self) -> None:
545551
"""

0 commit comments

Comments
 (0)