[New-bugs-announce] [issue42810] Nested if/else gets phantom else trace (3.10)

Ned Batchelder report at bugs.python.org
Sat Jan 2 10:09:25 EST 2021


New submission from Ned Batchelder <ned at nedbatchelder.com>:

(Using CPython commit 6b1ac809b9)

This program never executes line 6, but tracing it claims that it does:

    a = b = x = y = z = 1
    if a == 1:
        if b == 1:
            x = 4
        else:
            y = 6
    else:
        z = 8
    assert (a, b, x, y, z) == (1, 1, 4, 1, 1)

Using a simple trace program (https://github.com/nedbat/coveragepy/blob/master/lab/run_trace.py), it produces this output:

    call <string> 1 @-1
        line <string> 1 @0
        line <string> 2 @20
        line <string> 3 @28
        line <string> 4 @36
        line <string> 6 @40
        line <string> 9 @52
        return <string> 9 @76

----------
components: Interpreter Core
messages: 384222
nosy: Mark.Shannon, nedbat
priority: normal
severity: normal
status: open
title: Nested if/else gets phantom else trace (3.10)
versions: Python 3.10

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42810>
_______________________________________


More information about the New-bugs-announce mailing list