Skip to content

Commit

Permalink
Just do a simple textual substitution to avoid under matching when th…
Browse files Browse the repository at this point in the history
…e file is compiled.
  • Loading branch information
jaraco committed Aug 17, 2024
1 parent 4ea81bf commit 792da5a
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions importlib_resources/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,13 @@ def _(cand: None) -> types.ModuleType:
return resolve(_infer_caller().f_globals['__name__'])


@functools.lru_cache
def _this_filename():
frame = inspect.currentframe()
return __file__ if frame is None else inspect.getframeinfo(frame).filename


def _infer_caller():
"""
Walk the stack and find the frame of the first caller not in this module.
"""

def is_this_file(frame_info):
return frame_info.filename == _this_filename()
return frame_info.filename == __file__.replace('.pyc', '.py')

def is_wrapper(frame_info):
return frame_info.function == 'wrapper'
Expand Down

0 comments on commit 792da5a

Please sign in to comment.