Skip to content

Commit

Permalink
Avoid KeyError in distutils hack when pip is imported during ensurepip.
Browse files Browse the repository at this point in the history
Fixes #2940.
  • Loading branch information
jaraco committed Dec 21, 2021
1 parent 82726bb commit 137ab9d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion _distutils_hack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ def pip_imported_during_build(cls):

@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()
Expand Down
1 change: 1 addition & 0 deletions changelog.d/2940.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoid KeyError in distutils hack when pip is imported during ensurepip.

0 comments on commit 137ab9d

Please sign in to comment.