(self, co, m)
| 405 | yield "relative_import", (level, fromlist, name) |
| 406 | |
| 407 | def scan_code(self, co, m): |
| 408 | scanner = self.scan_opcodes |
| 409 | for what, args in scanner(co): |
| 410 | if what == "store": |
| 411 | name, = args |
| 412 | m.globalnames[name] = 1 |
| 413 | elif what == "absolute_import": |
| 414 | fromlist, name = args |
| 415 | have_star = 0 |
| 416 | if fromlist is not None: |
| 417 | if "*" in fromlist: |
| 418 | have_star = 1 |
| 419 | fromlist = [f for f in fromlist if f != "*"] |
| 420 | self._safe_import_hook(name, m, fromlist, level=0) |
| 421 | if have_star: |
| 422 | # We've encountered an "import *". If it is a Python module, |
| 423 | # the code has already been parsed and we can suck out the |
| 424 | # global names. |
| 425 | mm = None |
| 426 | if m.__path__: |
| 427 | # At this point we don't know whether 'name' is a |
| 428 | # submodule of 'm' or a global module. Let's just try |
| 429 | # the full name first. |
| 430 | mm = self.modules.get(m.__name__ + "." + name) |
| 431 | if mm is None: |
| 432 | mm = self.modules.get(name) |
| 433 | if mm is not None: |
| 434 | m.globalnames.update(mm.globalnames) |
| 435 | m.starimports.update(mm.starimports) |
| 436 | if mm.__code__ is None: |
| 437 | m.starimports[name] = 1 |
| 438 | else: |
| 439 | m.starimports[name] = 1 |
| 440 | elif what == "relative_import": |
| 441 | level, fromlist, name = args |
| 442 | if name: |
| 443 | self._safe_import_hook(name, m, fromlist, level=level) |
| 444 | else: |
| 445 | parent = self.determine_parent(m, level=level) |
| 446 | self._safe_import_hook(parent.__name__, None, fromlist, level=0) |
| 447 | else: |
| 448 | # We don't expect anything else from the generator. |
| 449 | raise RuntimeError(what) |
| 450 | |
| 451 | for c in co.co_consts: |
| 452 | if isinstance(c, type(co)): |
| 453 | self.scan_code(c, m) |
| 454 | |
| 455 | def load_package(self, fqname, pathname): |
| 456 | self.msgin(2, "load_package", fqname, pathname) |
no test coverage detected