From 830cf1f85470c665aa51a59b0e02f88822e8bfc3 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Thu, 27 Oct 2022 19:45:34 +0100 Subject: [PATCH] Prevent pip exception with version check (#2624) --- src/ansiblelint/config.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/ansiblelint/config.py b/src/ansiblelint/config.py index e0a32ce190..511618d7ae 100644 --- a/src/ansiblelint/config.py +++ b/src/ansiblelint/config.py @@ -227,7 +227,6 @@ def guess_install_method() -> str: from pip._internal.metadata import get_default_environment from pip._internal.req.req_uninstall import uninstallation_paths - try: dist = get_default_environment().get_distribution(package_name) if dist: logging.debug("Found %s dist", dist) @@ -236,10 +235,9 @@ def guess_install_method() -> str: else: logging.debug("Skipping %s as it is not installed.", package_name) use_pip = False - except UninstallationError as exc: - logging.debug(exc) - use_pip = False - except ImportError: + except (UninstallationError, AttributeError, ImportError) as exc: + # On Fedora 36, we got a AttributeError exception from pip that we want to avoid + logging.debug(exc) use_pip = False # We only want to recommend pip for upgrade if it looks safe to do so.