Skip to content

Commit 50efc2a

Browse files
webknjazpradyunsg
andcommitted
Use None-sentinel for missing alternative wheel
Co-authored-by: Pradyun Gedam <[email protected]>
1 parent bce6e3a commit 50efc2a

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

Lib/ensurepip/__init__.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sys
44
import sysconfig
55
import tempfile
6-
from contextlib import nullcontext, suppress
6+
from contextlib import nullcontext
77
from importlib import resources
88
from pathlib import Path
99
from shutil import copy2
@@ -24,11 +24,7 @@
2424

2525
def _find_wheel_pkg_dir_pip():
2626
if _WHEEL_PKG_DIR is None:
27-
raise LookupError(
28-
'The compile-time `WHEEL_PKG_DIR` is unset so there is '
29-
'no place for looking up the wheels.',
30-
) from None
31-
27+
return None
3228

3329
dist_matching_wheels = _WHEEL_PKG_DIR.glob(f'pip-*.whl')
3430
try:
@@ -43,8 +39,8 @@ def _find_wheel_pkg_dir_pip():
4339

4440
def _get_pip_whl_path_ctx():
4541
# Prefer pip from the wheel package directory, if present.
46-
with suppress(LookupError):
47-
return _find_wheel_pkg_dir_pip()
42+
if (alternative_pip_wheel_path := _find_wheel_pkg_dir_pip()) is not None:
43+
return alternative_pip_wheel_path
4844

4945
return resources.as_file(
5046
resources.files('ensurepip')

0 commit comments

Comments
 (0)