Bug: Windows guard in is_available() compares os.system (a function) to 'nt' — always False
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Open httpie/output/ui/man_pages.py and start at is_available(). Verify the current platform check against the reproduction shown in the issue, then correct the Windows guard. Done means Windows returns False before attempting to run man, while non-Windows behavior remains unchanged.
Written by the indexing model from the issue text.
Description
Description
In httpie/output/ui/man_pages.py, is_available() tries to short-circuit on Windows but the check is broken:
https://github.com/httpie/cli/blob/master/httpie/output/ui/man_pages.py#L21
def is_available(program: str) -> bool:
if NO_MAN_PAGES or os.system == 'nt':
return False
...
os.system is a built-in function object, so os.system == 'nt' is always False. The intended Windows guard never fires. The author almost certainly meant os.name == 'nt'.
Why it is wrong
os.systemis<built-in function system>; comparing a callable to the string'nt'is alwaysFalse.- The correct, idiomatic Windows check is
os.name == 'nt'(orsys.platform == 'win32').
Impact
On Windows the if NO_MAN_PAGES or os.system == 'nt': branch is dead code. The function does not short-circuit; instead it falls through to subprocess.run(['man', '1', program]). On a typical Windows install man is absent, so FileNotFoundError is raised and swallowed by the except Exception: return False, yielding the same observable result — but only by accident. If a man executable happens to be on PATH (e.g. Git Bash / WSL), HTTPie will attempt to render man pages on Windows, contrary to the intent of the guard. Also, relying on a swallowed exception for control flow is fragile.
Reproduction / verification
import os
print(os.system == 'nt') # -> False (regardless of platform)
print(os.name == 'nt') # -> True on Windows, 'posix' elsewhere
Suggested fix
import sys
...
def is_available(program: str) -> bool:
if NO_MAN_PAGES or sys.platform == 'win32':
return False
...
(Using sys.platform == 'win32' is the most robust Windows detector.)
Affected version
Current master (verified via git clone --depth 1).
- Dominant language
- Python
- Stars
- 38.6k
- Forks
- 4k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from httpie/cli
-
new
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
bug new
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
Similar issues
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
simonw/sqlite-utils#872 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100