File tree Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ async def interactive_shell():
43
43
# Run echo loop. Read text from stdin, and reply it back.
44
44
while True :
45
45
try :
46
- result = await session .prompt ( async_ = True )
46
+ result = await session .prompt_async ( )
47
47
print ('You said: "{0}"' .format (result ))
48
48
except (EOFError , KeyboardInterrupt ):
49
49
return
Original file line number Diff line number Diff line change 1
1
import sys
2
2
from typing import Optional , TextIO , cast
3
3
4
+ from prompt_toolkit .patch_stdout import StdoutProxy
4
5
from prompt_toolkit .utils import (
5
6
get_term_environment_variable ,
6
7
is_conemu_ansi ,
@@ -31,6 +32,12 @@ def create_output(stdout: Optional[TextIO] = None) -> Output:
31
32
else :
32
33
stdout = sys .stderr
33
34
35
+ # If the patch_stdout context manager has been used, then sys.stdout is
36
+ # replaced by this proxy. For prompt_toolkit applications, we want to use
37
+ # the real stdout.
38
+ while isinstance (stdout , StdoutProxy ):
39
+ stdout = stdout .original_stdout
40
+
34
41
if is_windows ():
35
42
from .conemu import ConEmuOutput
36
43
from .win32 import Win32Output
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ def write_and_flush() -> None:
102
102
def write_and_flush_in_loop () -> None :
103
103
# If an application is running, use `run_in_terminal`, otherwise
104
104
# call it directly.
105
- run_in_terminal (write_and_flush , in_executor = False )
105
+ run_in_terminal . run_in_terminal (write_and_flush , in_executor = False )
106
106
107
107
# Make sure `write_and_flush` is executed *in* the event loop, not in
108
108
# another thread.
@@ -155,3 +155,6 @@ def fileno(self) -> int:
155
155
"""
156
156
# This is important for code that expects sys.stdout.fileno() to work.
157
157
return self .original_stdout .fileno ()
158
+
159
+ def isatty (self ) -> bool :
160
+ return self .original_stdout .isatty ()
You can’t perform that action at this time.
0 commit comments