summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_dis.py
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2022-04-21 15:10:37 (GMT)
committerGitHub <noreply@github.com>2022-04-21 15:10:37 (GMT)
commit944fffee8916cb94321fa33cd3a43f4108717746 (patch)
treef88202dd13021ad5cf4b260ecf05ebab6015a5f6 /Lib/test/test_dis.py
parent2a5f171759a31597032cfe52646929e6f8727243 (diff)
downloadcpython-944fffee8916cb94321fa33cd3a43f4108717746.zip
cpython-944fffee8916cb94321fa33cd3a43f4108717746.tar.gz
cpython-944fffee8916cb94321fa33cd3a43f4108717746.tar.bz2
GH-88116: Use a compact format to represent end line and column offsets. (GH-91666)
* Stores all location info in linetable to conform to PEP 626. * Remove column table from code objects. * Remove end-line table from code objects. * Document new location table format
Diffstat (limited to 'Lib/test/test_dis.py')
-rw-r--r--Lib/test/test_dis.py23
1 files changed, 5 insertions, 18 deletions
diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py
index f560a55..0bd589d 100644
--- a/Lib/test/test_dis.py
+++ b/Lib/test/test_dis.py
@@ -196,7 +196,7 @@ def bug42562():
# Set line number for 'pass' to None
-bug42562.__code__ = bug42562.__code__.replace(co_linetable=b'\x04\x80')
+bug42562.__code__ = bug42562.__code__.replace(co_linetable=b'\xf8')
dis_bug42562 = """\
@@ -1560,32 +1560,19 @@ class InstructionTests(InstructionTestCase):
@requires_debug_ranges()
def test_co_positions_missing_info(self):
code = compile('x, y, z', '<test>', 'exec')
- code_without_column_table = code.replace(co_columntable=b'')
- actual = dis.get_instructions(code_without_column_table)
+ code_without_location_table = code.replace(co_linetable=b'')
+ actual = dis.get_instructions(code_without_location_table)
for instruction in actual:
with self.subTest(instruction=instruction):
positions = instruction.positions
self.assertEqual(len(positions), 4)
if instruction.opname == "RESUME":
continue
- self.assertEqual(positions.lineno, 1)
- self.assertEqual(positions.end_lineno, 1)
+ self.assertIsNone(positions.lineno)
+ self.assertIsNone(positions.end_lineno)
self.assertIsNone(positions.col_offset)
self.assertIsNone(positions.end_col_offset)
- code_without_endline_table = code.replace(co_endlinetable=b'')
- actual = dis.get_instructions(code_without_endline_table)
- for instruction in actual:
- with self.subTest(instruction=instruction):
- positions = instruction.positions
- self.assertEqual(len(positions), 4)
- if instruction.opname == "RESUME":
- continue
- self.assertEqual(positions.lineno, 1)
- self.assertIsNone(positions.end_lineno)
- self.assertIsNotNone(positions.col_offset)
- self.assertIsNotNone(positions.end_col_offset)
-
# get_instructions has its own tests above, so can rely on it to validate
# the object oriented API
class BytecodeTests(InstructionTestCase, DisTestBase):