Skip to content

Commit be21d82

Browse files
committed
Move exception suppression to cover more of self-version-check logic
This correctly suppresses issues around building networking sessions for a self version check.
1 parent 8eadcab commit be21d82

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

src/pip/_internal/cli/index_command.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,15 @@ def handle_pip_version_check(self, options: Values) -> None:
156156
if options.disable_pip_version_check or options.no_index:
157157
return
158158

159-
# Otherwise, check if we're using the latest version of pip available.
160-
session = self._build_session(
161-
options,
162-
retries=0,
163-
timeout=min(5, options.timeout),
164-
)
165-
with session:
166-
_pip_self_version_check(session, options)
159+
try:
160+
# Otherwise, check if we're using the latest version of pip available.
161+
session = self._build_session(
162+
options,
163+
retries=0,
164+
timeout=min(5, options.timeout),
165+
)
166+
with session:
167+
_pip_self_version_check(session, options)
168+
except Exception:
169+
logger.warning("There was an error checking the latest version of pip.")
170+
logger.debug("See below for error", exc_info=True)

src/pip/_internal/self_outdated_check.py

+10-14
Original file line numberDiff line numberDiff line change
@@ -232,17 +232,13 @@ def pip_self_version_check(session: PipSession, options: optparse.Values) -> Non
232232
if not installed_dist:
233233
return
234234

235-
try:
236-
upgrade_prompt = _self_version_check_logic(
237-
state=SelfCheckState(cache_dir=options.cache_dir),
238-
current_time=datetime.datetime.now(datetime.timezone.utc),
239-
local_version=installed_dist.version,
240-
get_remote_version=functools.partial(
241-
_get_current_remote_pip_version, session, options
242-
),
243-
)
244-
if upgrade_prompt is not None:
245-
logger.warning("%s", upgrade_prompt, extra={"rich": True})
246-
except Exception:
247-
logger.warning("There was an error checking the latest version of pip.")
248-
logger.debug("See below for error", exc_info=True)
235+
upgrade_prompt = _self_version_check_logic(
236+
state=SelfCheckState(cache_dir=options.cache_dir),
237+
current_time=datetime.datetime.now(datetime.timezone.utc),
238+
local_version=installed_dist.version,
239+
get_remote_version=functools.partial(
240+
_get_current_remote_pip_version, session, options
241+
),
242+
)
243+
if upgrade_prompt is not None:
244+
logger.warning("%s", upgrade_prompt, extra={"rich": True})

0 commit comments

Comments
 (0)