MCPcopy Index your code
hub / github.com/python/cpython / _make_lazycache_entry

Function _make_lazycache_entry

Lib/linecache.py:224–248  ·  view source on GitHub ↗
(filename, module_globals)

Source from the content-addressed store, hash-verified

222
223
224def _make_lazycache_entry(filename, module_globals):
225 if not filename or (filename.startswith('<') and filename.endswith('>')):
226 return None
227
228 if module_globals is not None and not isinstance(module_globals, dict):
229 raise TypeError(f'module_globals must be a dict, not {type(module_globals).__qualname__}')
230 if not module_globals or '__name__' not in module_globals:
231 return None
232
233 spec = module_globals.get('__spec__')
234 name = getattr(spec, 'name', None) or module_globals['__name__']
235 if name is None:
236 return None
237
238 loader = _bless_my_loader(module_globals)
239 if loader is None:
240 return None
241
242 get_source = getattr(loader, 'get_source', None)
243 if get_source is None:
244 return None
245
246 def get_lines(name=name, *args, **kwargs):
247 return get_source(name, *args, **kwargs)
248 return (get_lines,)
249
250def _bless_my_loader(module_globals):
251 # Similar to _bless_my_loader() in importlib._bootstrap_external,

Callers 2

updatecacheFunction · 0.85
lazycacheFunction · 0.85

Calls 4

_bless_my_loaderFunction · 0.70
startswithMethod · 0.45
endswithMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…