(filename, module_globals)
| 222 | |
| 223 | |
| 224 | def _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 | |
| 250 | def _bless_my_loader(module_globals): |
| 251 | # Similar to _bless_my_loader() in importlib._bootstrap_external, |
no test coverage detected
searching dependent graphs…