From b215120b5ab1315c963ee409b720753ac690c7f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20La=C3=ADns?= Date: Sat, 26 Sep 2020 14:41:42 +0100 Subject: [PATCH] Revert "Merge pull request #8391 from VikramJayanthi17/error-swallow-fix" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 7a60395dbd646401192252c4c2834607ff05fa96, reversing changes made to d3ce025e8dac297fe550e2acfa730288d715b6a7. It fixes devendored pip. See #8916. Signed-off-by: Filipe LaĆ­ns --- src/pip/_vendor/__init__.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/pip/_vendor/__init__.py b/src/pip/_vendor/__init__.py index 581db54c8..c3db83ff6 100644 --- a/src/pip/_vendor/__init__.py +++ b/src/pip/_vendor/__init__.py @@ -32,11 +32,15 @@ def vendored(modulename): try: __import__(modulename, globals(), locals(), level=0) except ImportError: - # This error used to be silenced in earlier variants of this file, to instead - # raise the error when pip actually tries to use the missing module. - # Based on inputs in #5354, this was changed to explicitly raise the error. - # Re-raising the exception without modifying it is an intentional choice. - raise + # We can just silently allow import failures to pass here. If we + # got to this point it means that ``import pip._vendor.whatever`` + # failed and so did ``import whatever``. Since we're importing this + # upfront in an attempt to alias imports, not erroring here will + # just mean we get a regular import error whenever pip *actually* + # tries to import one of these modules to use it, which actually + # gives us a better error message than we would have otherwise + # gotten. + pass else: sys.modules[vendored_name] = sys.modules[modulename] base, head = vendored_name.rsplit(".", 1)