Ensure that echo mode is enabled. Some tools such as PDB disable it which causes usability issues after a reload.
()
| 415 | |
| 416 | |
| 417 | def ensure_echo_on() -> None: |
| 418 | """Ensure that echo mode is enabled. Some tools such as PDB disable |
| 419 | it which causes usability issues after a reload.""" |
| 420 | # tcgetattr will fail if stdin isn't a tty |
| 421 | if sys.stdin is None or not sys.stdin.isatty(): |
| 422 | return |
| 423 | |
| 424 | try: |
| 425 | import termios |
| 426 | except ImportError: |
| 427 | return |
| 428 | |
| 429 | attributes = termios.tcgetattr(sys.stdin) |
| 430 | |
| 431 | if not attributes[3] & termios.ECHO: |
| 432 | attributes[3] |= termios.ECHO |
| 433 | termios.tcsetattr(sys.stdin, termios.TCSANOW, attributes) |
| 434 | |
| 435 | |
| 436 | def run_with_reloader( |
no test coverage detected