[New-bugs-announce] [issue3936] Faulty suppression of 'as' keyword warning

Terry J. Reedy report at bugs.python.org
Mon Sep 22 23:52:21 CEST 2008


New submission from Terry J. Reedy <tjreedy at udel.edu>:

Copied from c.l.p post by F. Lundh
I have no idea if this has implications for warnings in 2.6
------------------------

>  >>> from sympy.mpmath import specfun
>  >>>
>
> So what could be suppressing the warning?
[about 'as' becoming a keyword, when assigned to]

a bug in Python 2.5, it seems:

> more f1.py
as = 1
as = 2
as = 3
> python f1.py
f1.py:1: Warning: 'as' will become a reserved keyword in Python 2.6
f1.py:2: Warning: 'as' will become a reserved keyword in Python 2.6
f1.py:3: Warning: 'as' will become a reserved keyword in Python 2.6

> more f2.py
as = 1
import os
as = 3
> python f2.py
f2.py:1: Warning: 'as' will become a reserved keyword in Python 2.6

A quick look in parsetok.c reveals that it sets a "handling_import" flag
when it stumbles upon an "import" statement, a flag that's later used to
suppress the warning message.  The bug is that the flag isn't reset
until the parser sees an ENDMARKER token (end of file), instead of when
it sees the next NEWLINE token.

(if someone wants to submit this to bugs.python.org, be my guest)

----------
components: Interpreter Core
messages: 73600
nosy: tjreedy
severity: normal
status: open
title: Faulty suppression of 'as' keyword warning
versions: Python 2.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3936>
_______________________________________


More information about the New-bugs-announce mailing list