If the shim's been installed, but the system library is missing, then check_system_sitepackages currently raises Exception.
Since check_system_sitepackages() will only be called as a result of import selinux it would make more sense for this to raise an ImportError rather than the more generic Exception.
This can currently cause problems with things like a Python 3.9 virtual environment on RHEL8 where only the 3.6 bindings are shipped. If something pulls selinux into the venv as a dependency suddenly the usual practice of using except ImportError to catch the missing bindings won't work.
If the shim's been installed, but the system library is missing, then
check_system_sitepackagescurrently raisesException.Since
check_system_sitepackages()will only be called as a result ofimport selinuxit would make more sense for this to raise anImportErrorrather than the more genericException.This can currently cause problems with things like a Python 3.9 virtual environment on RHEL8 where only the 3.6 bindings are shipped. If something pulls
selinuxinto the venv as a dependency suddenly the usual practice of usingexcept ImportErrorto catch the missing bindings won't work.