]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
#1920: when considering a block starting by "while 0", the compiler optimized the
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>
Thu, 24 Jan 2008 22:51:18 +0000 (22:51 +0000)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>
Thu, 24 Jan 2008 22:51:18 +0000 (22:51 +0000)
commit16570f59caecde43b13b0e5f4c9328e4ceded544
tree4e85aacb3816816b40bc6e099313b234734781b0
parent5310b6941965afa3a40e61e8315590c931dc47e6
#1920: when considering a block starting by "while 0", the compiler optimized the
whole construct away, even when an 'else' clause is present::

    while 0:
        print("no")
    else:
        print("yes")

did not generate any code at all.

Now the compiler emits the 'else' block, like it already does for 'if' statements.

Will backport.
Lib/test/test_grammar.py
Python/compile.c