summaryrefslogtreecommitdiff
path: root/_distutils_hack
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2021-12-20 19:46:08 -0500
committerJason R. Coombs <jaraco@jaraco.com>2021-12-20 19:46:08 -0500
commit137ab9d684075f772c322f455b0dd1f992ddcd8f (patch)
tree0100724796202228617d9e25d7c46f1312adf928 /_distutils_hack
parent82726bbb8c799bd39e98422495e268bd7b50ca41 (diff)
downloadpython-setuptools-git-137ab9d684075f772c322f455b0dd1f992ddcd8f.tar.gz
Avoid KeyError in distutils hack when pip is imported during ensurepip. Fixes #2940.
Diffstat (limited to '_distutils_hack')
-rw-r--r--_distutils_hack/__init__.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/_distutils_hack/__init__.py b/_distutils_hack/__init__.py
index da51b433..22bc9ed6 100644
--- a/_distutils_hack/__init__.py
+++ b/_distutils_hack/__init__.py
@@ -119,7 +119,11 @@ class DistutilsMetaFinder:
@staticmethod
def frame_file_is_setup(frame):
- return frame.f_globals['__file__'].endswith('setup.py')
+ """
+ Return True if the indicated frame suggests a setup.py file.
+ """
+ # some frames may not have __file__ (#2940)
+ return frame.f_globals.get('__file__', '').endswith('setup.py')
DISTUTILS_FINDER = DistutilsMetaFinder()