mirror of
https://github.com/python/cpython.git
synced 2025-08-24 10:45:53 +00:00
bpo-45923: Handle call events in bytecode (GH-30364)
* Add a RESUME instruction to handle "call" events.
This commit is contained in:
parent
3e43fac250
commit
e028ae99ec
13 changed files with 672 additions and 523 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue