mirror of
https://github.com/python/cpython.git
synced 2026-01-04 22:42:14 +00:00
bpo-42246: Don't forget the entry block when ensuring that all exits have a line number (GH-23636)
Don't forget the entry block when ensuring that all exits have a line number.
This commit is contained in:
parent
f24b8101a0
commit
eaccc12aa9
4 changed files with 28 additions and 4 deletions
|
|
@ -809,6 +809,24 @@ def save_caller_frame():
|
|||
func(save_caller_frame)
|
||||
self.assertEqual(frame.f_lineno-frame.f_code.co_firstlineno, lastline)
|
||||
|
||||
def test_lineno_after_no_code(self):
|
||||
def no_code1():
|
||||
"doc string"
|
||||
|
||||
def no_code2():
|
||||
a: int
|
||||
|
||||
for func in (no_code1, no_code2):
|
||||
with self.subTest(func=func):
|
||||
code = func.__code__
|
||||
lines = list(code.co_lines())
|
||||
self.assertEqual(len(lines), 1)
|
||||
start, end, line = lines[0]
|
||||
self.assertEqual(start, 0)
|
||||
self.assertEqual(end, len(code.co_code))
|
||||
self.assertEqual(line, code.co_firstlineno)
|
||||
|
||||
|
||||
def test_big_dict_literal(self):
|
||||
# The compiler has a flushing point in "compiler_dict" that calls compiles
|
||||
# a portion of the dictionary literal when the loop that iterates over the items
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue