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: Let assign to as raise SyntaxWarning as well
Type: Stage:
Components: Interpreter Core Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: nnorwitz Nosy List: georg.brandl, gerrit, nnorwitz
Priority: low Keywords:

Created on 2003-02-23 17:08 by gerrit, last changed 2022-04-10 16:07 by admin. This issue is now closed.

Messages (5)
msg14779 - (view) Author: Gerrit Holl (gerrit) Date: 2003-02-23 17:08
according to the Python Language Reference Manual:
> In some future version of Python, the identifiers
> as and None will both become keywords.

Hence, it seems natural to me to raise a SyntaxWarning
when assigning to
either of these. However, the current Python
implementation doesn't:

103 >>> None="foo"
<stdin>:1: SyntaxWarning: assignment to None
104 >>> as="foo"
105 >>>

For consistency and cleanliness, assignment to 'as'
should raise a SyntaxWarning as well. Currently, it's
possible to not know it'll be a keyword and use it as a
variable; people shouldn't, so a SyntaxWarning would be
good.
msg14780 - (view) Author: Gerrit Holl (gerrit) Date: 2003-02-23 17:21
Logged In: YES 
user_id=13298

I'm not sure whether this should be considered as a feature.
I'd call it a minor wart... I'm also not sure about the
category, is this 'Python interpreter core' or am I right
with 'parser/compiler'?
msg14781 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-05-31 11:23
Logged In: YES 
user_id=1188172

This may be too late if as becomes a keyword in the new
with/do/whatever-statement...
msg14782 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-08-31 21:59
Logged In: YES 
user_id=1188172

For Py2.5, "with" and "as" will become keywords. However,
that will need "from __future__ import with_statement".

So I suggest to raise SyntaxWarning in 2.5 without this
statement if with or as are used as names.
msg14783 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2006-10-07 22:37
Logged In: YES 
user_id=33168

The warning was added for 2.5 and 2.6 this produces an error.

Python 2.5 (release25-maint:51996M, Sep 26 2006, 00:14:14)
>>> as = None
<stdin>:1: Warning: 'as' will become a reserved keyword in
Python 2.6

Python 2.6a0 (trunk:51986M, Oct  7 2006, 15:36:46)
>>> as = None
  File "<stdin>", line 1
    as = None
     ^
SyntaxError: invalid syntax
History
Date User Action Args
2022-04-10 16:07:02adminsetgithub: 38032
2003-02-23 17:08:04gerritcreate