MCPcopy Create free account
hub / github.com/RustPython/RustPython / _infer_caller

Function _infer_caller

Lib/importlib/resources/_common.py:90–105  ·  view source on GitHub ↗

Walk the stack and find the frame of the first caller not in this module.

()

Source from the content-addressed store, hash-verified

88
89
90def _infer_caller():
91 """
92 Walk the stack and find the frame of the first caller not in this module.
93 """
94
95 def is_this_file(frame_info):
96 return frame_info.filename == stack[0].filename
97
98 def is_wrapper(frame_info):
99 return frame_info.function == 'wrapper'
100
101 stack = inspect.stack()
102 not_this_file = itertools.filterfalse(is_this_file, stack)
103 # also exclude 'wrapper' due to singledispatch in the call stack
104 callers = itertools.filterfalse(is_wrapper, not_this_file)
105 return next(callers).frame
106
107
108def from_package(package: types.ModuleType):

Callers 1

_Function · 0.85

Calls 1

nextFunction · 0.85

Tested by

no test coverage detected