Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fake positions on CPython implementations only
  • Loading branch information
picnixz committed Aug 22, 2024
commit b3bc26f235e7f7f62c597847d1f61308fba73ea0
11 changes: 8 additions & 3 deletions Lib/test/test_dis.py
Original file line number Diff line number Diff line change
Expand Up @@ -974,8 +974,13 @@ def format_instr_positions(instr):
expected = dis_f_with_positions_format % positions
self.do_disassembly_test(_f, expected, show_positions=True)

@cpython_only
@requires_debug_ranges()
def test_dis_with_some_positions(self):
# If this test fails, it means that the construction of co_linetable
# has been changed. Please update this test and the internal docs
# accordingly so that they stay in sync.

def f():
pass

Expand All @@ -995,15 +1000,15 @@ def f():
(1 << 7)
| (PY_CODE_LOCATION_INFO_NO_COLUMNS << 3)
| (1 - 1), # 1 code unit (RESUME)
(1 << 1), # start line offset is 0 (encoded as an svarint)
(1 << 1), # start line offset (encoded as an svarint)
(1 << 7)
| (PY_CODE_LOCATION_INFO_NO_LOCATION << 3)
| (1 - 1), # 1 code unit (NOP)
(1 << 7)
| (PY_CODE_LOCATION_INFO_WITH_COLUMNS << 3)
| (1 - 1), # 1 code unit (RETURN CONST)
(2 << 1), # start line offset is 0 (encoded as an svarint)
3, # end line offset is 0 (varint encoded)
(2 << 1), # start line offset (encoded as an svarint)
3, # end line offset (encoded as a varint)
1, # 1-based start column (reported as COL - 1)
5, # 1-based end column (reported as ENDCOL - 1)
]
Expand Down