[New-bugs-announce] [issue18208] Wrong bytecode generated for 'in' operation

Phil Connell report at bugs.python.org
Fri Jun 14 10:42:34 CEST 2013


New submission from Phil Connell:

The following two expressions should have the same value:

Python 3.4.0a0 (default:fae92309c3be, Jun 14 2013, 09:29:54) 
[GCC 4.8.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 1 in [2] == False
False
>>> (1 in [2]) == False
True


It looks like this is a compiler issue - there shouldn't be a jump if the 'in' expression is false:

>>> dis.dis("1 in [2] == False")
  1           0 LOAD_CONST               0 (1)
              3 LOAD_CONST               1 (2)
              6 BUILD_LIST               1
              9 DUP_TOP             
             10 ROT_THREE           
             11 COMPARE_OP               6 (in)
             14 JUMP_IF_FALSE_OR_POP    24
             17 LOAD_CONST               2 (False)
             20 COMPARE_OP               2 (==)
             23 RETURN_VALUE        
        >>   24 ROT_TWO             
             25 POP_TOP             
             26 RETURN_VALUE        
>>>

----------
components: Interpreter Core
messages: 191108
nosy: benjamin.peterson, brett.cannon, georg.brandl, isoschiz, ncoghlan, pconnell
priority: normal
severity: normal
status: open
title: Wrong bytecode generated for 'in' operation

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


More information about the New-bugs-announce mailing list