diff --git a/importlib_resources/_common.py b/importlib_resources/_common.py index 364e4c0..0566035 100644 --- a/importlib_resources/_common.py +++ b/importlib_resources/_common.py @@ -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'