Skip to content

Commit 792da5a

Browse files
committed
Just do a simple textual substitution to avoid under matching when the file is compiled.
1 parent 4ea81bf commit 792da5a

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

importlib_resources/_common.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,13 @@ def _(cand: None) -> types.ModuleType:
8787
return resolve(_infer_caller().f_globals['__name__'])
8888

8989

90-
@functools.lru_cache
91-
def _this_filename():
92-
frame = inspect.currentframe()
93-
return __file__ if frame is None else inspect.getframeinfo(frame).filename
94-
95-
9690
def _infer_caller():
9791
"""
9892
Walk the stack and find the frame of the first caller not in this module.
9993
"""
10094

10195
def is_this_file(frame_info):
102-
return frame_info.filename == _this_filename()
96+
return frame_info.filename == __file__.replace('.pyc', '.py')
10397

10498
def is_wrapper(frame_info):
10599
return frame_info.function == 'wrapper'

0 commit comments

Comments
 (0)