Skip to content

Commit

Permalink
Suppress AttributeError when detecting get-pip. Fixes #3002.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jan 6, 2022
1 parent 4a5a4dd commit 2504699
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions _distutils_hack/__init__.py
Expand Up @@ -73,6 +73,17 @@ def do_override():
ensure_local_distutils()


class suppress(contextlib.suppress, contextlib.ContextDecorator):
"""
A version of contextlib.suppress with decorator support.
>>> @suppress(KeyError)
... def key_error():
... {}['']
>>> key_error()
"""


class DistutilsMetaFinder:
def find_spec(self, fullname, path, target=None):
if path is not None:
Expand Down Expand Up @@ -133,6 +144,7 @@ def pip_imported_during_build(cls):
)

@classmethod
@suppress(AttributeError)
def is_get_pip(cls):
"""
Detect if get-pip is being invoked. Ref #2993.
Expand Down
1 change: 1 addition & 0 deletions changelog.d/3002.misc.rst
@@ -0,0 +1 @@
Suppress AttributeError when detecting get-pip.

0 comments on commit 2504699

Please sign in to comment.