File tree Expand file tree Collapse file tree 1 file changed +3
-8
lines changed
Expand file tree Collapse file tree 1 file changed +3
-8
lines changed Original file line number Diff line number Diff line change @@ -87,24 +87,19 @@ 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-
9690def _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 == stack [ 0 ]. filename
10397
10498 def is_wrapper (frame_info ):
10599 return frame_info .function == 'wrapper'
106100
107- not_this_file = itertools .filterfalse (is_this_file , inspect .stack ())
101+ stack = inspect .stack ()
102+ not_this_file = itertools .filterfalse (is_this_file , stack )
108103 # also exclude 'wrapper' due to singledispatch in the call stack
109104 callers = itertools .filterfalse (is_wrapper , not_this_file )
110105 return next (callers ).frame
You can’t perform that action at this time.
0 commit comments