1
0
mirror of https://github.com/django/django.git synced 2025-08-08 19:09:15 +00:00

Refs #30323 -- Simplified utils.autoreload.ensure_echo_on().

This commit is contained in:
Tom Forbes 2019-04-29 10:07:00 +02:00 committed by Mariusz Felisiak
parent ed880d92b5
commit b5259ab780

View File

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