py-solc-x icon indicating copy to clipboard operation
py-solc-x copied to clipboard

use python built-in shutil.which instead of shelling out

Open f0rki opened this issue 3 years ago • 0 comments
trafficstars

What I did

So my original issue was that running which without stderr being redirected to /dev/null results in an ugly error message, when running solcx on a new system without any solc (e.g., in a container).

I switched to python's builtin shutil.which instead of using subprocess, which fixes this and avoids spawning a new process. It is part of the standard library so it should work on all platforms and behave equally. However I have only tested on linux.

How to verify it

previously:

$ python -c 'import solcx; print(solcx.import_installed_solc())'
which: no solc in ($PATH)
[]

and now:

$ python -c 'import solcx; print(solcx.import_installed_solc())'
[]

Checklist

  • [x] I have confirmed that my PR passes all linting checks
  • [ ] I have included test cases
  • [ ] I have updated the documentation (README.md)
  • [ ] I have added an entry to the changelog

f0rki avatar Dec 10 '21 19:12 f0rki