[pypy-issue] Issue #2916: py3.6 variable annotation breaks ternary expression (pypy/pypy)

Ryan Hileman issues-reply at bitbucket.org
Sun Nov 18 13:24:36 EST 2018


New issue 2916: py3.6 variable annotation breaks ternary expression
https://bitbucket.org/pypy/pypy/issues/2916/py36-variable-annotation-breaks-ternary

Ryan Hileman:

`var: bool = True if False else False`

In python3.6, this sets `var` to `False`.
In pypy's py3.6 branch, it sets `var` to `(True, False, False)`. Seems like a parsing or AST error.

pypy3:
```
  2           0 LOAD_CONST               1 ((True, False, False))
              2 STORE_FAST               0 (var)
              4 LOAD_CONST               0 (None)
              6 RETURN_VALUE
```

python3.7:
```
  2           0 LOAD_CONST               1 (False)
              2 POP_JUMP_IF_FALSE        8
              4 LOAD_CONST               2 (True)
              6 JUMP_FORWARD             2 (to 10)
        >>    8 LOAD_CONST               1 (False)
        >>   10 STORE_FAST               0 (var)
             12 LOAD_CONST               0 (None)
             14 RETURN_VALUE
```

Is this a bug in constant folding?

This works as expected:
```
var: bool
var = True if False else False
```




More information about the pypy-issue mailing list