summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2026-08-14 08:47:07 -0500
committerGitHub <noreply@github.com>2026-08-14 08:47:07 -0500
commit1650cbcc8897629041cc86131c6dd00fa2d6f336 (patch)
treea056ec60074710c50d6cd563d3a5a4ae0468bc47 /python
parent94fd8a0f43578012f2ab7f2cd76eedca3b4ac5bb (diff)
parent62c6eb54233dd4d09c19b6190a50be754c9e1e4f (diff)
downloadvyos-1x-1650cbcc8897629041cc86131c6dd00fa2d6f336.tar.gz
vyos-1x-1650cbcc8897629041cc86131c6dd00fa2d6f336.zip
Merge pull request #5402 from vyos/revert-5390-T9185-commit-confirm-cpu-spin
utils: T9185: revert the proposed fix ask_yes_no() busy-looping forever on non-tty stdin
Diffstat (limited to 'python')
-rw-r--r--python/vyos/utils/io.py21
1 files changed, 2 insertions, 19 deletions
diff --git a/python/vyos/utils/io.py b/python/vyos/utils/io.py
index 58ceb3476..77e30cbb0 100644
--- a/python/vyos/utils/io.py
+++ b/python/vyos/utils/io.py
@@ -55,25 +55,8 @@ def ask_input(question, default='', numeric_only=False, valid_responses=[],
return response
def ask_yes_no(question, default=False) -> bool:
- """Ask a yes/no question via input() and return their answer.
-
- Raises EOFError immediately if stdin is not a TTY (e.g. non-interactive
- scripts), instead of ever calling input(). A silent default here has
- caused real incidents (T9185): a caller that forgets to guard an
- interactive-only prompt gets no error and no visible hang, just a
- process quietly pegging a core. Callers that are meant to run
- non-interactively must check for that explicitly (see the no_prompt
- parameter used across config_mgmt.py/backend.py) rather than rely on
- this function to fall back to a default.
- """
- from sys import stdin, stdout
-
- if not stdin.isatty():
- raise EOFError(
- f'Cannot prompt "{question}" ([Y/n] default={default}): '
- 'stdin is not a TTY. Pass an explicit non-interactive option '
- '(e.g. no_prompt/-y) instead of relying on ask_yes_no().'
- )
+ """Ask a yes/no question via input() and return their answer."""
+ from sys import stdout
default_msg = "[Y/n]" if default else "[y/N]"
while True:
try: