1. Ned Batchelder
  2. coverage.py
  3. Issues
Issue #130 invalid

Wrong branch detection with nested try / if / for

Christian Heimes
created an issue

Branch detection gets nested try / if / for blocks wrong. I've broken down code from our code base as a simple example. The example has a missing jump from the for loop to the except body. In our code base it's a jump from the for loop to the else block.

def func(a):
    return a

def example(a):
    try:
        if a:
            for x in a: # no jump to line 10
                func(x)
        else:
            func(a)
    except Exception: # pragma: no cover
        pass # line 10

example([])
example([1])

Python: 2.7.1 Coverage: 3.5a1

Comments (2)

  1. Log in to comment