Skip to content

Commit 38b4e62

Browse files
committed
Only wrap self.stdin and self.stdout if they differ from sys equivalents.
1 parent 24dfb2b commit 38b4e62

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cmd2/cmd2.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,8 +645,10 @@ def _(event: Any) -> None: # pragma: no cover
645645

646646
if self.stdin.isatty():
647647
try:
648-
kwargs["input"] = create_input(stdin=self.stdin)
649-
kwargs["output"] = create_output(stdout=self.stdout)
648+
if self.stdin != sys.stdin:
649+
kwargs["input"] = create_input(stdin=self.stdin)
650+
if self.stdout != sys.stdout:
651+
kwargs["output"] = create_output(stdout=self.stdout)
650652
return PromptSession(**kwargs)
651653

652654
except (NoConsoleScreenBufferError, AttributeError, ValueError):

0 commit comments

Comments
 (0)