Commit 077b8e1
vlkumiloslearning
fix: replace subprocess which with shutil.which() in Process.exists()
The previous approach shelled out to the `which` binary via Popen, which
has three problems:
- `which` is not present on all systems (Alpine, minimal Docker images),
causing an unhandled FileNotFoundError on every exists() call
- any non-path text on stdout (e.g. zsh built-in printing "foo not found"
to stdout) produced a false positive
- spawning a subprocess for a PATH lookup is unnecessary overhead
shutil is already imported and shutil.which() is already used by
_resolve_tool() in the same class, as well as system_check.py and
dependency.py. Using it here is consistent and correct on all platforms.1 parent f62df1a commit 077b8e1
1 file changed
Lines changed: 1 addition & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
| 203 | + | |
208 | 204 | | |
209 | 205 | | |
210 | 206 | | |
| |||
0 commit comments