File tree 1 file changed +3
-8
lines changed 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:
87
87
return resolve (_infer_caller ().f_globals ['__name__' ])
88
88
89
89
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
-
96
90
def _infer_caller ():
97
91
"""
98
92
Walk the stack and find the frame of the first caller not in this module.
99
93
"""
100
94
101
95
def is_this_file (frame_info ):
102
- return frame_info .filename == _this_filename ()
96
+ return frame_info .filename == stack [ 0 ]. filename
103
97
104
98
def is_wrapper (frame_info ):
105
99
return frame_info .function == 'wrapper'
106
100
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 )
108
103
# also exclude 'wrapper' due to singledispatch in the call stack
109
104
callers = itertools .filterfalse (is_wrapper , not_this_file )
110
105
return next (callers ).frame
You can’t perform that action at this time.
0 commit comments