Refs -- Simplified utils.autoreload.ensure_echo_on().
@@ -78,17 +78,20 @@ def raise_last_exception():
def ensure_echo_on():
- if termios:
- fd = sys.stdin
- if fd.isatty():
- attr_list = termios.tcgetattr(fd)
+ """
+ Ensure that echo mode is enabled. Some tools such as PDB disable
+ it which causes usability issues after reload.
+ """
+ if not termios or not sys.stdin.isatty():
+ return
+ attr_list = termios.tcgetattr(sys.stdin)
if not attr_list[3] & termios.ECHO:
attr_list[3] |= termios.ECHO
if hasattr(signal, 'SIGTTOU'):
old_handler = signal.signal(signal.SIGTTOU, signal.SIG_IGN)
else:
old_handler = None
- termios.tcsetattr(fd, termios.TCSANOW, attr_list)
+ termios.tcsetattr(sys.stdin, termios.TCSANOW, attr_list)
if old_handler is not None:
signal.signal(signal.SIGTTOU, old_handler)
