diff options
author | Mark Shannon <mark@hotpy.org> | 2022-01-06 13:09:25 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-06 13:09:25 +0000 |
commit | e028ae99ecee671c0e8a3eabb829b5b2acfc4441 (patch) | |
tree | 497e68f1caeb92104bf3a464977bb0e024131f69 /Lib/test/test_code.py | |
parent | 3e43fac2503afe219336742b150b3ef6e470686f (diff) | |
download | cpython-e028ae99ecee671c0e8a3eabb829b5b2acfc4441.tar.gz cpython-e028ae99ecee671c0e8a3eabb829b5b2acfc4441.zip |
bpo-45923: Handle call events in bytecode (GH-30364)
* Add a RESUME instruction to handle "call" events.
Diffstat (limited to 'Lib/test/test_code.py')
-rw-r--r-- | Lib/test/test_code.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Lib/test/test_code.py b/Lib/test/test_code.py index 88f6c782a68..9319f200e34 100644 --- a/Lib/test/test_code.py +++ b/Lib/test/test_code.py @@ -367,7 +367,7 @@ class CodeTest(unittest.TestCase): # get assigned the first_lineno but they don't have other positions. # There is no easy way of inferring them at that stage, so for now # we don't support it. - self.assertTrue(positions.count(None) in [0, 4]) + self.assertIn(positions.count(None), [0, 3, 4]) if not any(positions): artificial_instructions.append(instr) @@ -378,6 +378,7 @@ class CodeTest(unittest.TestCase): for instruction in artificial_instructions ], [ + ('RESUME', 0), ("PUSH_EXC_INFO", None), ("LOAD_CONST", None), # artificial 'None' ("STORE_NAME", "e"), # XX: we know the location for this @@ -419,7 +420,9 @@ class CodeTest(unittest.TestCase): def func(): x = 1 new_code = func.__code__.replace(co_linetable=b'') - for line, end_line, column, end_column in new_code.co_positions(): + positions = new_code.co_positions() + next(positions) # Skip RESUME at start + for line, end_line, column, end_column in positions: self.assertIsNone(line) self.assertEqual(end_line, new_code.co_firstlineno + 1) @@ -428,7 +431,9 @@ class CodeTest(unittest.TestCase): def func(): x = 1 new_code = func.__code__.replace(co_endlinetable=b'') - for line, end_line, column, end_column in new_code.co_positions(): + positions = new_code.co_positions() + next(positions) # Skip RESUME at start + for line, end_line, column, end_column in positions: self.assertEqual(line, new_code.co_firstlineno + 1) self.assertIsNone(end_line) @@ -437,7 +442,9 @@ class CodeTest(unittest.TestCase): def func(): x = 1 new_code = func.__code__.replace(co_columntable=b'') - for line, end_line, column, end_column in new_code.co_positions(): + positions = new_code.co_positions() + next(positions) # Skip RESUME at start + for line, end_line, column, end_column in positions: self.assertEqual(line, new_code.co_firstlineno + 1) self.assertEqual(end_line, new_code.co_firstlineno + 1) self.assertIsNone(column) |