[New-bugs-announce] [issue46344] 3.11: except/else/if/raise traced incorrectly

Ned Batchelder report at bugs.python.org
Tue Jan 11 08:10:52 EST 2022


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

This code shows a raise inside an except/else/if that isn't run, but incorrectly appears in the trace output (see the ***** line):


$ cat arcs_1160.py
def func(x):
    try:
        b = 6
    except ZeroDivisionError:
        pass
    else:
        if x == "raise":
            raise ValueError()
    finally:
        f = 23

func("other")

$ python3.10 -c "import sys; print(sys.version)"
3.10.1 (main, Dec 14 2021, 08:30:13) [Clang 12.0.0 (clang-1200.0.32.29)]

$ python3.10 -m trace --trace arcs_1160.py
 --- modulename: arcs_1160, funcname: <module>
arcs_1160.py(1): def func(x):
arcs_1160.py(12): func("other")
 --- modulename: arcs_1160, funcname: func
arcs_1160.py(2):     try:
arcs_1160.py(3):         b = 6
arcs_1160.py(7):         if x == "raise":
arcs_1160.py(10):         f = 23

$ python3.11 -c "import sys; print(sys.version)"
3.11.0a3+ (heads/main:d24cd49acb, Jan 11 2022, 07:29:41) [Clang 12.0.0 (clang-1200.0.32.29)]

$ python3.11 -m trace --trace arcs_1160.py
 --- modulename: arcs_1160, funcname: <module>
arcs_1160.py(1): def func(x):
arcs_1160.py(12): func("other")
 --- modulename: arcs_1160, funcname: func
arcs_1160.py(2):     try:
arcs_1160.py(3):         b = 6
arcs_1160.py(7):         if x == "raise":
arcs_1160.py(8):             raise ValueError()      <<**********
arcs_1160.py(10):         f = 23

----------
components: Interpreter Core
keywords: 3.11regression
messages: 410300
nosy: Mark.Shannon, nedbat
priority: normal
severity: normal
status: open
title: 3.11: except/else/if/raise traced incorrectly
versions: Python 3.11

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


More information about the New-bugs-announce mailing list