mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Mark POP_TOP at end of expression statement as artificial, to conform to PEP 626. (GH-24860)
This commit is contained in:
parent
35d5068928
commit
c5440937ef
2 changed files with 10 additions and 0 deletions
|
@ -786,6 +786,14 @@ if 1:
|
||||||
self.assertIn('LOAD_', opcodes[0].opname)
|
self.assertIn('LOAD_', opcodes[0].opname)
|
||||||
self.assertEqual('RETURN_VALUE', opcodes[1].opname)
|
self.assertEqual('RETURN_VALUE', opcodes[1].opname)
|
||||||
|
|
||||||
|
def test_lineno_procedure_call(self):
|
||||||
|
def call():
|
||||||
|
(
|
||||||
|
print()
|
||||||
|
)
|
||||||
|
line1 = call.__code__.co_firstlineno + 1
|
||||||
|
assert line1 not in [line for (_, _, line) in call.__code__.co_lines()]
|
||||||
|
|
||||||
def test_lineno_after_implicit_return(self):
|
def test_lineno_after_implicit_return(self):
|
||||||
TRUE = True
|
TRUE = True
|
||||||
# Don't use constant True or False, as compiler will remove test
|
# Don't use constant True or False, as compiler will remove test
|
||||||
|
|
|
@ -3397,6 +3397,8 @@ compiler_visit_stmt_expr(struct compiler *c, expr_ty value)
|
||||||
}
|
}
|
||||||
|
|
||||||
VISIT(c, expr, value);
|
VISIT(c, expr, value);
|
||||||
|
/* Mark POP_TOP as artificial */
|
||||||
|
c->u->u_lineno = -1;
|
||||||
ADDOP(c, POP_TOP);
|
ADDOP(c, POP_TOP);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue