Open
Description
Describe the bug
for some reason a triple-nested context manager seems to confuse branch coverage in python 3.14
To Reproduce
minimal reproduction:
import contextlib
@contextlib.contextmanager
def ctx():
yield
def f():
with ctx():
with ctx():
with ctx():
print(1)
f()
with 3.14:
$ bash -xc 'python --version --version && coverage --version && coverage erase && coverage run --branch -m t && coverage report --show-missing'
+ python --version --version
Python 3.14.0b3 (main, Jun 18 2025, 08:59:11) [GCC 13.3.0]
+ coverage --version
Coverage.py, version 7.9.2a0.dev1 with C extension
Full documentation is at https://coverage.readthedocs.io/en/7.9.2a0.dev1
+ coverage erase
+ coverage run --branch -m t
1
+ coverage report --show-missing
Name Stmts Miss Branch BrPart Cover Missing
---------------------------------------------------
t.py 10 0 2 2 83% 13->14, 13->exit
---------------------------------------------------
TOTAL 10 0 2 2 83%
Expected behavior
3.13 behaviour:
$ bash -xc 'python --version --version && coverage --version && coverage erase && coverage run --branch -m t && coverage report --show-missing'
+ python --version --version
Python 3.13.5 (main, Jun 12 2025, 08:56:14) [GCC 13.3.0]
+ coverage --version
Coverage.py, version 7.9.2a0.dev1 with C extension
Full documentation is at https://coverage.readthedocs.io/en/7.9.2a0.dev1
+ coverage erase
+ coverage run --branch -m t
1
+ coverage report --show-missing
Name Stmts Miss Branch BrPart Cover Missing
---------------------------------------------------
t.py 10 0 2 0 100%
---------------------------------------------------
TOTAL 10 0 2 0 100%
Additional context
this was tickled by flake8's testsuite -- it works fine with two contexts for some reason though 🤷