semantic-check: fail fast on a tty instead of hanging on stdin - #319
Open
Ar9av wants to merge 1 commit into
Open
semantic-check: fail fast on a tty instead of hanging on stdin#319Ar9av wants to merge 1 commit into
Ar9av wants to merge 1 commit into
Conversation
A bare `prismor semantic-check` (or an empty-string argument) on an interactive terminal fell through to `sys.stdin.read()`, which blocks until EOF. With no argument and nobody piping input, the command just hung with no prompt and no hint — it reads as the tool being broken. (Verified with a real pty: old code still waiting after 5s; only Ctrl-D turned it into "no text provided".) Guard the stdin fallback with `sys.stdin.isatty()`, the same pattern `prismor unlock` already uses: when stdin is a terminal and no text was given, print usage and exit 1 immediately. Piping (`echo ... | prismor semantic-check`) and the positional argument are unchanged. Tests: pty regression (bare invocation on a tty errors fast, never hangs) plus the empty-piped-stdin fast-error path, in test_cli.py.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A bare
prismor semantic-checkon an interactive terminal hangs. Reported as "semantic-check shows an error."text = args.text; if not text: text = sys.stdin.read()— with no argument (or an empty-string argument, which is falsy) it falls through tosys.stdin.read(), which blocks until EOF. On a real terminal with nobody piping input, the command just sits there with no prompt and no hint; the only way out is Ctrl-D, which then printserror: no text provided. Either way it reads as the tool being broken.Proven with a real pty (no input sent):
Fix
Guard the stdin fallback with
sys.stdin.isatty()— the same patternprismor unlockalready uses. When stdin is a terminal and no text was passed, print usage and exit 1 immediately:Piping (
echo … | prismor semantic-check) and the positional-argument path are unchanged.Testing
subprocess.TimeoutExpiredagainst the old code).tests/test_cli.py; verified on st3ve that piped/arg invocations still analyze normally.