diff options
| author | Tom Forbes <tom@tomforb.es> | 2019-04-29 10:07:00 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-04-29 11:41:00 +0200 |
| commit | b5259ab78054a91f10804de460128879f7948ca4 (patch) | |
| tree | 30456a88cc2fb4e991627a588f9a6b0dfce92cf1 /django | |
| parent | ed880d92b50c641c3e7f6e8ce5741085ffe1f8fb (diff) | |
Refs #30323 -- Simplified utils.autoreload.ensure_echo_on().
Diffstat (limited to 'django')
| -rw-r--r-- | django/utils/autoreload.py | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py index 4a68fb05d0..17631e15ef 100644 --- a/django/utils/autoreload.py +++ b/django/utils/autoreload.py @@ -78,19 +78,22 @@ def raise_last_exception(): def ensure_echo_on(): - if termios: - fd = sys.stdin - if fd.isatty(): - attr_list = termios.tcgetattr(fd) - 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) - if old_handler is not None: - signal.signal(signal.SIGTTOU, old_handler) + """ + 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(sys.stdin, termios.TCSANOW, attr_list) + if old_handler is not None: + signal.signal(signal.SIGTTOU, old_handler) def iter_all_python_module_files(): |
