[New-bugs-announce] [issue9866] Inconsistencies in tracing list comprehensions

Alexander Belopolsky report at bugs.python.org
Wed Sep 15 23:23:01 CEST 2010


New submission from Alexander Belopolsky <belopolsky at users.sourceforge.net>:

Attached test script, tracetest.py, prints disassembly followed by a trace of the following function:


1  def f():
2      return [i
3              for i
4              in range(2)]


With default configuration, the output is


  2           0 LOAD_CONST               1 (<code object <listcomp> at 0x100484e00, file "tracetest.py", line 2>) 
              3 MAKE_FUNCTION            0 

  4           6 LOAD_GLOBAL              0 (range) 
              9 LOAD_CONST               2 (2) 
             12 CALL_FUNCTION            1 
             15 GET_ITER             
             16 CALL_FUNCTION            1 
             19 RETURN_VALUE         
listcomp:
  2           0 BUILD_LIST               0 
              3 LOAD_FAST                0 (.0) 
        >>    6 FOR_ITER                12 (to 21) 

  3           9 STORE_FAST               1 (i) 
             12 LOAD_FAST                1 (i) 
             15 LIST_APPEND              2 
             18 JUMP_ABSOLUTE            6 
        >>   21 RETURN_VALUE         
['2 0 LOAD_CONST', '4 6 LOAD_GLOBAL', '2 0 BUILD_LIST', '3 9 STORE_FAST', '2 6 FOR_ITER', '3 9 STORE_FAST', '2 6 FOR_ITER']

but with configuration using --without-computed-gotos option, the disassembly is the same, but the trace is different:


['2 0 LOAD_CONST', '4 6 LOAD_GLOBAL', '2 0 BUILD_LIST', '2 6 FOR_ITER', '2 6 FOR_ITER']

This behavior changed between 3.1 and 3.2 (likely in r74132), but it is inconsistent in both versions.  Since r74132 changes were not backported to 3.1, I am classifying this as 3.2 only even though the problem is present in 3.1 as well.

See also issues #6042 and #9315.

----------
components: Interpreter Core
files: tracetest.py
messages: 116482
nosy: alexandre.vassalotti, amaury.forgeotdarc, belopolsky, collinwinter, eli.bendersky, ezio.melotti, flox, georg.brandl, jyasskin, pitrou, rhettinger, teresap989, terry.reedy
priority: normal
severity: normal
status: open
title: Inconsistencies in tracing list comprehensions
type: behavior
versions: Python 3.2
Added file: http://bugs.python.org/file18895/tracetest.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9866>
_______________________________________


More information about the New-bugs-announce mailing list