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
Deleting names referencing from enclosed and enclosing scopes #68984
Comments
While committing issue bpo-24129, I noticed the following in the execution model documentation: ================== I'm not sure what that means, as both of the following compiled fine for me under 3.4.2: >>> def f():
... x = 1
... def g():
... nonlocal x
... del x
...
>>> def f():
... x = 1
... del x
... def g():
... print(x)
... |
Note that I haven't attempted to resolve this myself, as I'm not sure if we should just delete the paragraph, or if we accidentally dropped a compile time error check that didn't have any tests somewhere along the line. Probably a good one to raise on python-dev... |
I wonder if it is a left-over from the behaviour prior to 3.2? In 3.1, I py> def outer(): See also the "Changed in 3.2" comment here: https://docs.python.org/3/reference/simple_stmts.html#the-del-statement |
It looks like it is safe to just remove this line from docs. This code >>> x = 1
>>> def f():
... global x
... del x
...
>>> f()
>>> x Works as expected, i.e. raises NameError. (The same happens for nonlocal but with UnboundLocalError.) |
Thanks for the PR, Ivan. Merged and backported to 3.5 and 3.6. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: