Skip to content
Merged
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
10 changes: 9 additions & 1 deletion prompt_toolkit/output/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ def create_output(stdout: Optional[TextIO] = None) -> Output:

:param stdout: The stdout object
"""
stdout = stdout or sys.__stdout__
if stdout is None:
# By default, render to stdout. If the output is piped somewhere else,
# render to stderr. The prompt_toolkit render output is not meant to be
# consumed by something other then a terminal, so this is a reasonable
# default.
if sys.stdout.isatty():
stdout = sys.stdout
else:
stdout = sys.stderr

if is_windows():
from .conemu import ConEmuOutput
Expand Down