(code, lasti=-1, varname_from_oparg=None,
names=None, co_consts=None, linestarts=None,
*, file=None, line_offset=0, exception_entries=(),
co_positions=None, show_caches=False)
| 540 | ) |
| 541 | |
| 542 | def _disassemble_bytes(code, lasti=-1, varname_from_oparg=None, |
| 543 | names=None, co_consts=None, linestarts=None, |
| 544 | *, file=None, line_offset=0, exception_entries=(), |
| 545 | co_positions=None, show_caches=False): |
| 546 | # Omit the line number column entirely if we have no line number info |
| 547 | show_lineno = bool(linestarts) |
| 548 | if show_lineno: |
| 549 | maxlineno = max(linestarts.values()) + line_offset |
| 550 | if maxlineno >= 1000: |
| 551 | lineno_width = len(str(maxlineno)) |
| 552 | else: |
| 553 | lineno_width = 3 |
| 554 | else: |
| 555 | lineno_width = 0 |
| 556 | maxoffset = len(code) - 2 |
| 557 | if maxoffset >= 10000: |
| 558 | offset_width = len(str(maxoffset)) |
| 559 | else: |
| 560 | offset_width = 4 |
| 561 | for instr in _get_instructions_bytes(code, varname_from_oparg, names, |
| 562 | co_consts, linestarts, |
| 563 | line_offset=line_offset, |
| 564 | exception_entries=exception_entries, |
| 565 | co_positions=co_positions, |
| 566 | show_caches=show_caches): |
| 567 | new_source_line = (show_lineno and |
| 568 | instr.starts_line is not None and |
| 569 | instr.offset > 0) |
| 570 | if new_source_line: |
| 571 | print(file=file) |
| 572 | is_current_instr = instr.offset == lasti |
| 573 | print(instr._disassemble(lineno_width, is_current_instr, offset_width), |
| 574 | file=file) |
| 575 | if exception_entries: |
| 576 | print("ExceptionTable:", file=file) |
| 577 | for entry in exception_entries: |
| 578 | lasti = " lasti" if entry.lasti else "" |
| 579 | end = entry.end-2 |
| 580 | print(f" {entry.start} to {end} -> {entry.target} [{entry.depth}]{lasti}", file=file) |
| 581 | |
| 582 | def _disassemble_str(source, **kwargs): |
| 583 | """Compile the source string, then disassemble the code object.""" |
no test coverage detected