Replacement for __import__()
(name, globals=None, locals=None, fromlist=None, level=-1)
| 240 | import_submodule(mod, item, buf + '.' + item) |
| 241 | |
| 242 | def deep_import_hook(name, globals=None, locals=None, fromlist=None, level=-1): |
| 243 | """Replacement for __import__()""" |
| 244 | parent, buf = get_parent(globals, level) |
| 245 | |
| 246 | head, name, buf = load_next(parent, None if level < 0 else parent, name, buf) |
| 247 | |
| 248 | tail = head |
| 249 | while name: |
| 250 | tail, name, buf = load_next(tail, tail, name, buf) |
| 251 | |
| 252 | # If tail is None, both get_parent and load_next found |
| 253 | # an empty module name: someone called __import__("") or |
| 254 | # doctored faulty bytecode |
| 255 | if tail is None: |
| 256 | raise ValueError('Empty module name') |
| 257 | |
| 258 | if not fromlist: |
| 259 | return head |
| 260 | |
| 261 | ensure_fromlist(tail, fromlist, buf, 0) |
| 262 | return tail |
| 263 | |
| 264 | modules_reloading = {} |
| 265 |
nothing calls this directly
no test coverage detected