From 6d8733602a1e72e5b5ac572f3e26c9157e776659 Mon Sep 17 00:00:00 2001 From: Joshua Bronson Date: Fri, 8 Nov 2024 14:25:09 -0500 Subject: [PATCH] Fix uncaught TypeError accessing setuptools_dist.version --- src/pip/_internal/network/session.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pip/_internal/network/session.py b/src/pip/_internal/network/session.py index 1765b4f6bd7..5a6a6e5fd6e 100644 --- a/src/pip/_internal/network/session.py +++ b/src/pip/_internal/network/session.py @@ -176,7 +176,12 @@ def user_agent() -> str: setuptools_dist = get_default_environment().get_distribution("setuptools") if setuptools_dist is not None: - data["setuptools_version"] = str(setuptools_dist.version) + try: + setuptools_version = setuptools_dist.version + except TypeError: + logging.debug("Caught TypeError accessing setuptools_dist.version") + else: + data["setuptools_version"] = str(setuptools_version) if shutil.which("rustc") is not None: # If for any reason `rustc --version` fails, silently ignore it