[issue42810] Nested if/else gets phantom else trace (3.10)

Pablo Galindo Salgado report at bugs.python.org
Sat Jan 2 21:37:42 EST 2021


Pablo Galindo Salgado <pablogsal at gmail.com> added the comment:

There is something wrong elsewhere as well because even if reverting that commit fix the problem:

❯ git reset --hard upstream/master
HEAD is now at bd2728b1e8 bpo-42806: Fix ast locations of f-strings inside parentheses (GH-24067)

~/github/python/master master*
❯ git revert 28b75c80dcc1e17ed3ac1c69362bf8dc164b760a
Removing Misc/NEWS.d/next/Core and Builtins/2020-12-22-20-30-11.bpo-42246.7BrPLg.rst
mak[master 444e7e11a8] Revert "bpo-42246: Don't eliminate jumps to jumps, if it will break PEP 626. (GH-23896)"
 7 files changed, 4605 insertions(+), 4707 deletions(-)
 delete mode 100644 Misc/NEWS.d/next/Core and Builtins/2020-12-22-20-30-11.bpo-42246.7BrPLg.rst
 rewrite Python/importlib_external.h (87%)
 rewrite Python/importlib_zipimport.h (85%)
e
~/github/python/master master* ⇡
❯ make -j -s
 CC='gcc -pthread' LDSHARED='gcc -pthread -shared    ' OPT='-g -Og -Wall'       _TCLTK_INCLUDES='' _TCLTK_LIBS=''       ./python -E ./setup.py -q build

The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc                  pwd                   time


~/github/python/master master* ⇡
❯ ./python -m trace --trace ./lel.py
 --- modulename: lel, funcname: <module>
lel.py(1): a = b = x = y = z = 1
lel.py(2): if a == 1:
lel.py(3):     if b == 1:
lel.py(4):         x = 4
lel.py(9): assert (a, b, x, y, z) == (1, 1, 4, 1, 1)

Not running the optimize_basic_block function:

diff --git a/Python/compile.c b/Python/compile.c
index 6698b55000..30a0305ef1 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -6074,6 +6074,7 @@ fold_tuple_on_constants(struct instr *inst,
 static int
 optimize_basic_block(basicblock *bb, PyObject *consts)
 {
+    return 0;
     assert(PyList_CheckExact(consts));
     struct instr nop;
     nop.i_opcode = NOP;

makes the problem appear again:

❯ make -j -s
 CC='gcc -pthread' LDSHARED='gcc -pthread -shared    ' OPT='-g -Og -Wall'       _TCLTK_INCLUDES='' _TCLTK_LIBS=''       ./python -E ./setup.py -q build

The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc                  pwd                   time


~/github/python/master master* ⇡
❯ ./python -m trace --trace ./lel.py
 --- modulename: lel, funcname: <module>
lel.py(1): a = b = x = y = z = 1
lel.py(2): if a == 1:
lel.py(3):     if b == 1:
lel.py(4):         x = 4
lel.py(6):         y = 6
lel.py(9): assert (a, b, x, y, z) == (1, 1, 4, 1, 1)

----------

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


More information about the Python-bugs-list mailing list