We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 795d866 commit b67d014Copy full SHA for b67d014
prompt_toolkit/output/defaults.py
@@ -21,7 +21,15 @@ def create_output(stdout: Optional[TextIO] = None) -> Output:
21
22
:param stdout: The stdout object
23
"""
24
- stdout = stdout or sys.__stdout__
+ if stdout is None:
25
+ # By default, render to stdout. If the output is piped somewhere else,
26
+ # render to stderr. The prompt_toolkit render output is not meant to be
27
+ # consumed by something other then a terminal, so this is a reasonable
28
+ # default.
29
+ if sys.stdout.isatty():
30
+ stdout = sys.stdout
31
+ else:
32
+ stdout = sys.stderr
33
34
if is_windows():
35
from .conemu import ConEmuOutput
0 commit comments