Skip to content

nonlocal bug to crash #1758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
youknowone opened this issue Feb 10, 2020 · 1 comment
Closed

nonlocal bug to crash #1758

youknowone opened this issue Feb 10, 2020 · 1 comment
Labels
C-compat A discrepancy between RustPython and CPython

Comments

@youknowone
Copy link
Member

Feature

code

def test_var_annot_refleak(self):
    # complex case: custom locals plus custom __annotations__
    # this was causing refleak
    cns = CNS()
    nonloc_ns = {'__annotations__': cns}
    class CNS2:
        def __init__(self):
            self._dct = {'__annotations__': cns}
        def __setitem__(self, item, value):
            nonlocal nonloc_ns
            self._dct[item] = value
            nonloc_ns[item] = value
        def __getitem__(self, item):
            return self._dct[item]
    exec('X: str', {}, CNS2())
    self.assertEqual(nonloc_ns['__annotations__']['x'], str)

expected result: silent exit without error

actual result:

SyntaxError: no binding for nonlocal 'nonloc_ns' found at line 0 column 0

Python Documentation

@youknowone youknowone added the C-compat A discrepancy between RustPython and CPython label Feb 10, 2020
@youknowone
Copy link
Member Author

fixed by #1951

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-compat A discrepancy between RustPython and CPython
Projects
None yet
Development

No branches or pull requests

1 participant