From 8eb95b5ad2ed1cee1204b1ce95bad9118063d178 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 12 Mar 2023 08:31:12 -0400 Subject: fix: recent pypy3.9 now omits lines after jumps We were seeing these failures in the nightly builds: ``` FAILED tests/test_arcs.py::LoopArcTest::test_continue - AssertionError: Possible arcs differ: minus is expected, plus is actual (-1, 1) # .1 (1, 2) # 12 (1, 5) # 15 (2, 3) # 23 (3, 1) # 31 - (4, 1) # 41 (5, -1) # 5. Missing arcs differ: minus is expected, plus is actual - (4, 1) # 41 + assert False FAILED tests/test_arcs.py::LoopArcTest::test_break - AssertionError: Possible arcs differ: minus is expected, plus is actual (-1, 1) # .1 (1, 2) # 12 (1, 5) # 15 (2, 3) # 23 (3, 5) # 35 - (4, 1) # 41 (5, -1) # 5. Missing arcs differ: minus is expected, plus is actual (1, 5) # 15 - (4, 1) # 41 assert False FAILED tests/test_arcs.py::ExceptionArcTest::test_raise_followed_by_statement - AssertionError: Possible arcs differ: minus is expected, plus is actual (-1, 1) # .1 (1, 2) # 12 (2, 3) # 23 (3, 4) # 34 (4, 6) # 46 - (5, 8) # 58 (6, 7) # 67 (7, 8) # 78 (8, -1) # 8. Missing arcs differ: minus is expected, plus is actual - (5, 8) # 58 + assert False FAILED tests/test_coverage.py::SimpleStatementTest::test_raise_followed_by_statement - AssertionError: [1, 2, 4, 5] != [1, 2, 3, 4, 5] assert [1, 2, 4, 5] == [1, 2, 3, 4, 5] At index 2 diff: 4 != 3 Right contains one more item: 5 Full diff: - [1, 2, 3, 4, 5] ? --- + [1, 2, 4, 5] FAILED tests/test_coverage.py::SimpleStatementTest::test_break - AssertionError: [1, 2, 3, 5] != [1, 2, 3, 4, 5] assert [1, 2, 3, 5] == [1, 2, 3, 4, 5] At index 3 diff: 5 != 4 Right contains one more item: 5 Full diff: - [1, 2, 3, 4, 5] ? --- + [1, 2, 3, 5] FAILED tests/test_coverage.py::SimpleStatementTest::test_continue - AssertionError: [1, 2, 3, 5] != [1, 2, 3, 4, 5] assert [1, 2, 3, 5] == [1, 2, 3, 4, 5] At index 3 diff: 5 != 4 Right contains one more item: 5 Full diff: - [1, 2, 3, 4, 5] ? --- + [1, 2, 3, 5] ``` --- coverage/env.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'coverage') diff --git a/coverage/env.py b/coverage/env.py index 5d69a234..b2229281 100644 --- a/coverage/env.py +++ b/coverage/env.py @@ -106,11 +106,17 @@ class PYBEHAVIOR: # Lines after break/continue/return/raise are no longer compiled into the # bytecode. They used to be marked as missing, now they aren't executable. - omit_after_jump = pep626 + omit_after_jump = ( + pep626 + or (PYPY and PYVERSION >= (3, 9) and PYPYVERSION >= (7, 3, 12)) + ) # PyPy has always omitted statements after return. omit_after_return = omit_after_jump or PYPY + # Optimize away unreachable try-else clauses. + optimize_unreachable_try_else = pep626 + # Modules used to have firstlineno equal to the line number of the first # real line of code. Now they always start at 1. module_firstline_1 = pep626 -- cgit v1.2.1