homepage

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.

classification
Title: Limit "global" keyword name conflicts in language spec to those enforced by CPython
Type: enhancement Stage: needs patch
Components: Versions: Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: alex, cvrebert, eric.araujo, ezio.melotti, fossilet, ncoghlan, rhettinger, terry.reedy
Priority: normal Keywords:

Created on 2012年04月11日 04:46 by ncoghlan, last changed 2022年04月11日 14:57 by admin.

Messages (4)
msg158005 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2012年04月11日 04:46
The language spec currently includes the following paragraph [1]:
 Names listed in a global statement must not be defined as
 formal parameters or in a for loop control target, class
 definition, function definition, or import statement.
While the first restriction is real (and enforced by CPython), since formal parameters are explicitly defined as local variables, there's no obvious rationale for the last 4 restrictions (and CPython doesn't enforce any of them).
The proposal is that the paragraph be simplified to:
 Names listed in a global statement must not also be defined as
 formal function parameters. Attempting to do so raises SyntaxError.
The current (incorrect!) CPython implementation detail note will be removed.
A similar clarification will also be made in the "nonlocal" statement documentation.
[1] http://docs.python.org/dev/reference/simple_stmts.html#the-global-statement 
msg158006 - (view) Author: Alex Gaynor (alex) * (Python committer) Date: 2012年04月11日 04:51
This shouldn't be a problem for PyPy, in fact I'm almost positive that we implement this already (since Django has a test that uses this "feature"). If/when the spec is changed please make sure there are tests for all these cases so we *know* it works though.
msg158007 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2012年04月11日 04:52
Thread link: http://mail.python.org/pipermail/python-ideas/2012-April/014783.html 
msg237252 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2015年03月05日 09:29
+1 for the proposed change. It should add there is also an enforced (and obvious) restriction that the variable not have been declared nonlocal.
History
Date User Action Args
2022年04月11日 14:57:29adminsetgithub: 58749
2015年03月05日 10:03:11ezio.melottisetnosy: + ezio.melotti
stage: needs patch

versions: + Python 3.5, - Python 3.3
2015年03月05日 09:29:58rhettingersetnosy: + rhettinger
messages: + msg237252
2015年03月05日 08:51:06fossiletsetnosy: + fossilet
2012年04月13日 17:18:24terry.reedysetnosy: + terry.reedy
2012年04月11日 05:28:54cvrebertsetnosy: + cvrebert
2012年04月11日 05:03:36eric.araujosetnosy: + eric.araujo
2012年04月11日 04:52:27ncoghlansetmessages: + msg158007
2012年04月11日 04:51:52alexsetnosy: + alex
messages: + msg158006
2012年04月11日 04:46:30ncoghlancreate

AltStyle によって変換されたページ (->オリジナル) /