Skip to content

Wrong branch coverage for Python 3.8 in try-return-finally #707

Closed
@lhupfeldt

Description

@lhupfeldt

Given the following program:

_val = None

def return_from_try_finaly(early):
    global _val
    _val = 1
    try:
        orig_val = _val
        _val = 2
        if early:
            return 1
    finally:
        _val = orig_val

    return 3


assert return_from_try_finaly(True) == 1
assert _val == 1

assert return_from_try_finaly(False) == 3
assert _val == 1

stored in try_return_finally.py

Shows full coverage for python 3.6:

$ python=python3.6; $python -m coverage run try_return_finally.py && $python -m coverage report -m
Name                    Stmts   Miss Branch BrPart      Cover   Missing
-----------------------------------------------------------------------
try_return_finally.py      14      0      4      0   100.000%

Partial branch for python 3.8:

$ python=python3.8; $python -m coverage run try_return_finally.py && $python -m coverage report -m
Name                    Stmts   Miss Branch BrPart      Cover   Missing
-----------------------------------------------------------------------
try_return_finally.py      14      0      4      1    94.444%   12->exit

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions