Repository navigation
Stop counting the try/else line when a with statement raises - #2301
Conversation
On Python 3.14 the not-taken with handler was walked into the following jump and the else line was reported as covered. Co-authored-by: Cursor <[email protected]>
|
Thanks, but it looks like PyPy needs some adjustment: https://github.com/coveragepy/coveragepy/actions/runs/36057278907/job/107827357129 Let me know if you want help with it. |
Co-authored-by: Cursor <[email protected]>
|
PyPy counted the try/else line because a line event fired while the opcode was PUSH_EXC_INFO. Commit 3aab736 returns before that line is recorded. The test file is unchanged. Local check on that commit: CPython and PyPy both passed that test locally. This note does not say the GitHub checks have finished. |
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
…set. Co-authored-by: Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
|
Thanks. tests/test_push_exc_info.py seemed like too deep a test of too many internal details, and it's not needed to verify the fix. Unless I've missed something? |
|
Hmm, now we seem not to be hitting this branch: if op in NO_FALL_THROUGH:
return Nonebut that was the fix, and we have a test, so what is missing? |
|
Oh, derp. That code is called from the tracer, so it's not covered |
On Python 3.14, branch coverage reported the
elsebody of atryas executed when the body was awiththat raised. The example in #2289 is awith contextlib.ExitStack()that raisesSystemExit. Theelseline that raisesRuntimeErrornever runs, but the report showed 100%.sys.monitoringdelivers the not-takenPOP_JUMP_IF_TRUEin thewithexception handler, and the destination isRERAISE.BranchArcResolverthen walked past thatRERAISEinto the swallowed-exception path, which jumps to theelseline.RERAISEdoes not fall through, so the walk now stops there and that arc is not recorded.tests/test_arcs.py::WithTest::test_bug_2289runs the example from #2289 and expects theelseline (raise RuntimeError) to be missing.Fixes #2289