Here's something interesting: sympy crashes in Python 2.6 (Windows)

Fredrik Lundh fredrik at pythonware.com
Mon Sep 22 17:20:35 EDT 2008


Robert Kern wrote:

> No warnings show up when importing the offending module:
> 
> Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04)
> [GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
>  >>> from sympy.mpmath import specfun
>  >>>
> 
> So what could be suppressing the warning?

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)

</F>




More information about the Python-list mailing list