Replacement for __import__()
(name, globals=None, locals=None, fromlist=None, level=-1)
| 224 | import_submodule(mod, item, buf + '.' + item) |
| 225 | |
| 226 | def deep_import_hook(name, globals=None, locals=None, fromlist=None, level=-1): |
| 227 | """Replacement for __import__()""" |
| 228 | parent, buf = get_parent(globals, level) |
| 229 | |
| 230 | head, name, buf = load_next(parent, None if level < 0 else parent, name, buf) |
| 231 | |
| 232 | tail = head |
| 233 | while name: |
| 234 | tail, name, buf = load_next(tail, tail, name, buf) |
| 235 | |
| 236 | # If tail is None, both get_parent and load_next found |
| 237 | # an empty module name: someone called __import__("") or |
| 238 | # doctored faulty bytecode |
| 239 | if tail is None: |
| 240 | raise ValueError('Empty module name') |
| 241 | |
| 242 | if not fromlist: |
| 243 | return head |
| 244 | |
| 245 | ensure_fromlist(tail, fromlist, buf, 0) |
| 246 | return tail |
| 247 | |
| 248 | modules_reloading = {} |
| 249 |
nothing calls this directly
no test coverage detected
searching dependent graphs…