Get the line number for a given bytecode offset Analogous to PyCode_Addr2Line; translated from pseudocode in Objects/lnotab_notes.txt
(self, addrq)
| 726 | _typename = 'PyCodeObject' |
| 727 | |
| 728 | def addr2line(self, addrq): |
| 729 | ''' |
| 730 | Get the line number for a given bytecode offset |
| 731 | |
| 732 | Analogous to PyCode_Addr2Line; translated from pseudocode in |
| 733 | Objects/lnotab_notes.txt |
| 734 | ''' |
| 735 | co_linetable = self.pyop_field('co_linetable').proxyval(set()) |
| 736 | |
| 737 | # Initialize lineno to co_firstlineno as per PyCode_Addr2Line |
| 738 | # not 0, as lnotab_notes.txt has it: |
| 739 | lineno = int_from_int(self.field('co_firstlineno')) |
| 740 | |
| 741 | if addrq < 0: |
| 742 | return lineno |
| 743 | addr = 0 |
| 744 | for addr, end_addr, line in parse_location_table(lineno, co_linetable): |
| 745 | if addr <= addrq and end_addr > addrq: |
| 746 | return line |
| 747 | assert False, "Unreachable" |
| 748 | |
| 749 | |
| 750 | def items_from_keys_and_values(keys, values): |
no test coverage detected