mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
gh-118465: Add __firstlineno__ attribute to class (GH-118475)
It is set by compiler with the line number of the first line of the class definition.
This commit is contained in:
parent
716ec4bfcf
commit
153b3f7530
17 changed files with 61 additions and 89 deletions
|
@ -1958,7 +1958,10 @@ class TestSourcePositions(unittest.TestCase):
|
|||
|
||||
def test_load_super_attr(self):
|
||||
source = "class C:\n def __init__(self):\n super().__init__()"
|
||||
code = compile(source, "<test>", "exec").co_consts[0].co_consts[1]
|
||||
for const in compile(source, "<test>", "exec").co_consts[0].co_consts:
|
||||
if isinstance(const, types.CodeType):
|
||||
code = const
|
||||
break
|
||||
self.assertOpcodeSourcePositionIs(
|
||||
code, "LOAD_GLOBAL", line=3, end_line=3, column=4, end_column=9
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue