[pypy-issue] Issue #3110: Interaction between exec() and nonlocal (pypy/pypy)

Ronan Lamy issues-reply at bitbucket.org
Fri Nov 8 15:28:31 EST 2019


New issue 3110: Interaction between exec() and nonlocal
https://bitbucket.org/pypy/pypy/issues/3110/interaction-between-exec-and-nonlocal

Ronan Lamy:

The following test, which passes on CPython 3.6.9, fails on the last line in PyPy:

```python
def test_exec_nonlocal():
    x = 0
    def set_x(value):
        nonlocal x
        x = value
    set_x(1)
    assert x == 1
    exec('set_x(2)')
    assert x == 2
```

The situation is a bit unclear according to the docs, but I think PyPy’s behaviour is incorrect.




More information about the pypy-issue mailing list