Skip to content

Commit

Permalink
Refs #30323 -- Simplified utils.autoreload.ensure_echo_on().
Browse files Browse the repository at this point in the history
  • Loading branch information
orf authored and felixxm committed Apr 29, 2019
1 parent ed880d9 commit b5259ab
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions django/utils/autoreload.py
Expand Up @@ -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():
Expand Down

3 comments on commit b5259ab

@blueyed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?
What about #11291?

@felixxm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ticket 30416 is waiting for review. If we will accept the ticket and patch then we can remove ensure_echo_on() in the future, so nothing has changed for #11291.

@blueyed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, just feels a bit unnecessary to me - would have been better to review 30416 then maybe.. ;)

Please sign in to comment.