FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-43950: support positions for dis.Instructions created through dis.Bytecode by isidentical · Pull Request #28142 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
3 changes: 2 additions & 1 deletion Lib/dis.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,8 @@ def __iter__(self):
co.co_names, co.co_consts,
self._linestarts,
line_offset=self._line_offset,
exception_entries=self.exception_entries)
exception_entries=self.exception_entries,
co_positions=co.co_positions())

def __repr__(self):
return "{}({!r})".format(self.__class__.__name__,
Expand Down
5 changes: 5 additions & 0 deletions Lib/test/test_dis.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1302,6 +1302,11 @@ def test_from_traceback_dis(self):
b = dis.Bytecode.from_traceback(tb)
self.assertEqual(b.dis(), dis_traceback)

@requires_debug_ranges()
def test_bytecode_co_positions(self):
bytecode = dis.Bytecode("a=1")
for instr, positions in zip(bytecode, bytecode.codeobj.co_positions()):
assert instr.positions == positions

class TestBytecodeTestCase(BytecodeTestCase):
def test_assert_not_in_with_op_not_in_bytecode(self):
Expand Down

Back | FazBrowse Home | New Git URL