[issue39746] Inappropriate short circuit relating to inequality comparison and membership test

Orion Fisher report at bugs.python.org
Mon Feb 24 22:08:43 EST 2020


New submission from Orion Fisher <OCFI222 at g.uky.edu>:

I found a strange issue with how the interpreter produces bytecode for an expression like True != True in [False, False].

Reading it, one would expect the value of the expression to be True, whether the inequality comparison is evaluated first, or the membership test is evaluated first. Indeed, when parentheses are used to control the order of execution these results do occur.

However, without any parentheses, the result is False. The underlying cause seems to be in a short circuit which is dependent on the inequality comparison, seen in the JUMP_IF_FALSE_OR_POP instruction.

This expression is very synthetic, but I am submitting this bug under the worry that it speaks to a more significant error in the bytecode produced for inequality tests (or membership tests).

----------
components: Interpreter Core
files: bug_occurence.py
messages: 362612
nosy: Orion Fisher
priority: normal
severity: normal
status: open
title: Inappropriate short circuit relating to inequality comparison and membership test
type: behavior
versions: Python 3.8
Added file: https://bugs.python.org/file48911/bug_occurence.py

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


More information about the Python-bugs-list mailing list