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

Function _bless_my_loader

Lib/linecache.py:250–278  ·  view source on GitHub ↗
(module_globals)

Source from the content-addressed store, hash-verified

248 return (get_lines,)
249
250def _bless_my_loader(module_globals):
251 # Similar to _bless_my_loader() in importlib._bootstrap_external,
252 # but always emits warnings instead of errors.
253 loader = module_globals.get('__loader__')
254 if loader is None and '__spec__' not in module_globals:
255 return None
256 spec = module_globals.get('__spec__')
257
258 # The __main__ module has __spec__ = None.
259 if spec is None and module_globals.get('__name__') == '__main__':
260 return loader
261
262 spec_loader = getattr(spec, 'loader', None)
263 if spec_loader is None:
264 import warnings
265 warnings.warn(
266 'Module globals is missing a __spec__.loader',
267 DeprecationWarning)
268 return loader
269
270 assert spec_loader is not None
271 if loader is not None and loader != spec_loader:
272 import warnings
273 warnings.warn(
274 'Module globals; __loader__ != __spec__.loader',
275 DeprecationWarning)
276 return loader
277
278 return spec_loader
279
280
281def _register_code(code, string, name):

Callers 1

_make_lazycache_entryFunction · 0.70

Calls 2

getMethod · 0.45
warnMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…