f
This commit is contained in:
22
API/HTTP.py
22
API/HTTP.py
@@ -52,12 +52,22 @@ def _resolve_verify_value(verify_ssl: bool) -> Union[bool, str]:
|
||||
|
||||
def _try_module_bundle(mod_name: str) -> Optional[str]:
|
||||
# Prefer checking sys.modules first (helps test injection / monkeypatching)
|
||||
try:
|
||||
mod = sys.modules.get(mod_name)
|
||||
if mod is None:
|
||||
mod = __import__(mod_name)
|
||||
except (ImportError, ModuleNotFoundError):
|
||||
return None
|
||||
mod = sys.modules.get(mod_name)
|
||||
if mod is None:
|
||||
# Avoid raising ModuleNotFoundError so debuggers and callers aren't interrupted.
|
||||
# Check for module availability before attempting to import it.
|
||||
try:
|
||||
import importlib.util
|
||||
|
||||
spec = importlib.util.find_spec(mod_name)
|
||||
if spec is None:
|
||||
return None
|
||||
import importlib
|
||||
|
||||
mod = importlib.import_module(mod_name)
|
||||
except Exception:
|
||||
# Treat any import/initialization failure as module not available.
|
||||
return None
|
||||
|
||||
# Common APIs that return a bundle path
|
||||
for attr in ("where", "get_ca_bundle", "bundle_path", "get_bundle_path", "get_bundle"):
|
||||
|
||||
Reference in New Issue
Block a user