diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2022-01-05 23:21:43 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2022-01-05 23:22:26 -0500 |
commit | 2504699e5f9acfdd1438512173f90b3f61114095 (patch) | |
tree | fc3933384d83187ea6b20f927582f20ff09ac3c3 /_distutils_hack | |
parent | 4a5a4ddfc432f1fc569aa5a76b2b68ebb4b2062f (diff) | |
download | python-setuptools-git-2504699e5f9acfdd1438512173f90b3f61114095.tar.gz |
Suppress AttributeError when detecting get-pip. Fixes #3002.
Diffstat (limited to '_distutils_hack')
-rw-r--r-- | _distutils_hack/__init__.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/_distutils_hack/__init__.py b/_distutils_hack/__init__.py index 4745f8b9..75bc4463 100644 --- a/_distutils_hack/__init__.py +++ b/_distutils_hack/__init__.py @@ -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: @@ -133,6 +144,7 @@ class DistutilsMetaFinder: ) @classmethod + @suppress(AttributeError) def is_get_pip(cls): """ Detect if get-pip is being invoked. Ref #2993. |