Skip to content

Guard click-repl import when stdin is unavailable - #140

Merged
auvipy merged 2 commits into
click-contrib:masterfrom
charan-rathore:guard-import-without-stdin-139
Oct 4, 2026
Merged

auvipy merged 2 commits into
click-contrib:masterfrom
charan-rathore:guard-import-without-stdin-139

Conversation

@charan-rathore

Copy link
Copy Markdown
Contributor

Closes #139.

click_repl checks sys.stdin.isatty() while importing. Python can set sys.stdin to None when standard input is unavailable, so the import fails before callers can use the package. Treat that case as non-interactive while preserving the existing isatty() check for a real stream.

Added a child-process regression that imports with standard input closed. The test failed with the reported AttributeError before the change.

Tests: pytest -q (71 passed, 5 skipped); flake8 click_repl tests.

Instinct assisted with the fix and tests.

@auvipy
auvipy self-requested a review September 29, 2026 09:55
@charan-rathore charan-rathore reopened this Oct 2, 2026
@auvipy auvipy reopened this Oct 4, 2026
@auvipy
auvipy merged commit 4b7ac51 into click-contrib:master Oct 4, 2026
28 checks passed
@charan-rathore
charan-rathore deleted the guard-import-without-stdin-139 branch October 4, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0.4.0: import click_repl raises AttributeError when sys.stdin is None (Windows services, pythonw, closed stdin)

2 participants