This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2015年08月05日 13:05 by ncoghlan, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 754 | merged | levkivskyi, 2017年03月21日 20:41 | |
| PR 774 | merged | Mariatta, 2017年03月23日 04:06 | |
| PR 775 | merged | Mariatta, 2017年03月23日 04:07 | |
| Messages (5) | |||
|---|---|---|---|
| msg248036 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2015年08月05日 13:05 | |
While committing issue #24129, I noticed the following in the execution model documentation: ================== If a variable is referenced in an enclosing scope, it is illegal to delete the name. An error will be reported at compile time. ================== 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) ... |
|||
| msg248040 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2015年08月05日 13:53 | |
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... |
|||
| msg248042 - (view) | Author: Steven D'Aprano (steven.daprano) * (Python committer) | Date: 2015年08月05日 14:48 | |
I wonder if it is a left-over from the behaviour prior to 3.2? In 3.1, I get this syntax error: py> def outer(): ... spam = 1 ... def inner(): ... nonlocal spam ... del spam ... inner() ... SyntaxError: can not delete variable 'spam' referenced in nested scope See also the "Changed in 3.2" comment here: https://docs.python.org/3/reference/simple_stmts.html#the-del-statement |
|||
| msg289811 - (view) | Author: Ivan Levkivskyi (levkivskyi) * (Python committer) | Date: 2017年03月18日 13:39 | |
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.) |
|||
| msg290022 - (view) | Author: Mariatta (Mariatta) * (Python committer) | Date: 2017年03月23日 04:08 | |
Thanks for the PR, Ivan. Merged and backported to 3.5 and 3.6. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:19 | admin | set | github: 68984 |
| 2017年03月23日 04:08:31 | Mariatta | set | status: open -> closed nosy: + Mariatta messages: + msg290022 resolution: fixed stage: needs patch -> resolved |
| 2017年03月23日 04:07:12 | Mariatta | set | pull_requests: + pull_request681 |
| 2017年03月23日 04:06:31 | Mariatta | set | pull_requests: + pull_request680 |
| 2017年03月21日 20:41:58 | levkivskyi | set | pull_requests: + pull_request667 |
| 2017年03月20日 14:44:46 | Mariatta | set | keywords:
+ easy stage: needs patch versions: + Python 3.5, Python 3.6, Python 3.7 |
| 2017年03月18日 13:39:06 | levkivskyi | set | messages: + msg289811 |
| 2015年08月05日 15:08:10 | levkivskyi | set | nosy:
+ levkivskyi |
| 2015年08月05日 14:48:55 | steven.daprano | set | nosy:
+ steven.daprano messages: + msg248042 |
| 2015年08月05日 14:47:18 | ncoghlan | set | messages: + msg248040 |
| 2015年08月05日 13:05:17 | ncoghlan | create | |