Skip to content

Commit

Permalink
Merge pull request #8391 from VikramJayanthi17/error-swallow-fix
Browse files Browse the repository at this point in the history
Re-think error swallowing for de-vendored packages #5354
  • Loading branch information
pradyunsg authored Jun 4, 2020
2 parents d3ce025 + 2244868 commit 7a60395
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Empty file added news/error-swallow.trivial
Empty file.
14 changes: 5 additions & 9 deletions src/pip/_vendor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,11 @@ def vendored(modulename):
try:
__import__(modulename, globals(), locals(), level=0)
except ImportError:
# 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
# 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
else:
sys.modules[vendored_name] = sys.modules[modulename]
base, head = vendored_name.rsplit(".", 1)
Expand Down

0 comments on commit 7a60395

Please sign in to comment.