Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Here's something interesting: sympy crashes in Python 2.6 (Windows)

Reply
Thread Tools

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

 
 
Mensanator
Guest
Posts: n/a
 
      09-20-2008
Beacuse in 2.6, Python apparently has fixed a discrepency that existed
in previous versions.

In the IDLE that comes with 2.5, typing "as", to wit "import random as
ran",
the words "import" and "as" highlight in red, so you can't use them as
variable
names or you'll get a syntax error.

Ah, but you CAN use "as" for a variable: "for as in xrange(10): print
as"
works just fine, although it shouldn't.

Python 2.6 fixes this discrepency and now gives you a syntax error if
you
use "as" for a variable name.

The upshot is code (such as sympy) written prior to 2.6 can crash now
due
to this fix if said code inadverntently used what should have been a
reserved
word.

I was able to fix the code for this "as" problem, but not the one that
came after. I've reported this and interested parties can visit the
sympy
page and check Issue 1115.
 
Reply With Quote
 
 
 
 
Guilherme Polo
Guest
Posts: n/a
 
      09-20-2008
On Sat, Sep 20, 2008 at 1:27 PM, Mensanator <(E-Mail Removed)> wrote:
> Beacuse in 2.6, Python apparently has fixed a discrepency that existed
> in previous versions.
>
> In the IDLE that comes with 2.5, typing "as", to wit "import random as
> ran",
> the words "import" and "as" highlight in red, so you can't use them as
> variable
> names or you'll get a syntax error.
>
> Ah, but you CAN use "as" for a variable: "for as in xrange(10): print
> as"
> works just fine, although it shouldn't.
>
> Python 2.6 fixes this discrepency and now gives you a syntax error if
> you
> use "as" for a variable name.


You should have noticed the warning you received in python 2.5 when
using "as" as a name.

>
> The upshot is code (such as sympy) written prior to 2.6 can crash now
> due
> to this fix if said code inadverntently used what should have been a
> reserved
> word.
>
> I was able to fix the code for this "as" problem, but not the one that
> came after. I've reported this and interested parties can visit the
> sympy
> page and check Issue 1115.
> --
> http://mail.python.org/mailman/listinfo/python-list
>




--
-- Guilherme H. Polo Goncalves
 
Reply With Quote
 
 
 
 
Mensanator
Guest
Posts: n/a
 
      09-20-2008
On Sep 20, 1:34�pm, "Guilherme Polo" <(E-Mail Removed)> wrote:
> On Sat, Sep 20, 2008 at 1:27 PM, Mensanator <(E-Mail Removed)> wrote:
> > Beacuse in 2.6, Python apparently has fixed a discrepency that existed
> > in previous versions.

>
> > In the IDLE that comes with 2.5, typing "as", to wit "import random as
> > ran",
> > the words "import" and "as" highlight in red, so you can't use them as
> > variable
> > names or you'll get a syntax error.

>
> > Ah, but you CAN use "as" for a variable: "for as in xrange(10): print
> > as"
> > works just fine, although it shouldn't.

>
> > Python 2.6 fixes this discrepency and now gives you a syntax error if
> > you
> > use "as" for a variable name.

>
> You should have noticed the warning you received in python 2.5 when
> using "as" as a name.


I'm not the one who wrote sympy, so I guess I'm not
the only one who didn't notice it.

If it's a well known problem, then sorry I wasted
your time.

The sympy people thought it was important and,
as not everyone uses sympy, I thought I was
performing a service to the community mentioning
it here.

Sheesh.

>
>
>
> > The upshot is code (such as sympy) written prior to 2.6 can crash now
> > due
> > to this fix if said code inadverntently used what should have been a
> > reserved
> > word.

>
> > I was able to fix the code for this "as" problem, but not the one that
> > came after. I've reported this and interested parties can visit the
> > sympy
> > page and check Issue 1115.
> > --
> >http://mail.python.org/mailman/listinfo/python-list

>
> --
> -- Guilherme H. Polo Goncalves- Hide quoted text -
>
> - Show quoted text -


 
Reply With Quote
 
Fredrik Lundh
Guest
Posts: n/a
 
      09-21-2008
Mensanator wrote:

> I'm not the one who wrote sympy, so I guess I'm not
> the only one who didn't notice it.
>
> If it's a well known problem, then sorry I wasted
> your time.


Given that 2.5 explicitly warns about this specific change:

>>> as = 1

<stdin>:1: Warning: 'as' will become a reserved keyword in Python 2.6

it's an unknown issue only for people who has 1) never used their code
under 2.5, or 2) never looks at the output produced by their programs.

The PEP-5 process guarantees that "users will have at least a year to
test their programs and migrate them from use of the deprecated
construct to the alternative one," and Python 2.5 was released *two*
years ago.

So it sure looks like the SimPy folks ignored the established process.
Why they've done that is probably a more interesting issue than the
change itself.

</F>

 
Reply With Quote
 
Mensanator
Guest
Posts: n/a
 
      09-21-2008
On Sep 21, 4:37 am, Fredrik Lundh <(E-Mail Removed)> wrote:
> Mensanator wrote:
> > I'm not the one who wrote sympy, so I guess I'm not
> > the only one who didn't notice it.

>
> > If it's a well known problem, then sorry I wasted
> > your time.

>
> Given that 2.5 explicitly warns about this specific change:
>
> >>> as = 1

> <stdin>:1: Warning: 'as' will become a reserved keyword in Python 2.6


Uh...how come _I_ don't see that?

In IDLE, I get:

Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
(Intel)] on win32

IDLE 1.2
>>> as = 1

SyntaxError: invalid syntax


When inside a script, I get:

as = 1
print as
>>> ====================== RESTART ======================
>>>

1


>
> it's an unknown issue only for people who has 1) never used their code
> under 2.5, or 2) never looks at the output produced by their programs.
>
> The PEP-5 process guarantees that "users will have at least a year to
> test their programs and migrate them from use of the deprecated
> construct to the alternative one," and Python 2.5 was released *two*
> years ago.
>
> So it sure looks like the SimPy folks ignored the established process.
> Why they've done that is probably a more interesting issue than the
> change itself.


Is there something wrong with my (and Sympy's) version
of Python that we don't see these warnings?

>
> </F>


 
Reply With Quote
 
Robert Kern
Guest
Posts: n/a
 
      09-22-2008
Fredrik Lundh wrote:
> Mensanator wrote:
>
>> I'm not the one who wrote sympy, so I guess I'm not
>> the only one who didn't notice it.
>>
>> If it's a well known problem, then sorry I wasted
>> your time.

>
> Given that 2.5 explicitly warns about this specific change:
>
> >>> as = 1

> <stdin>:1: Warning: 'as' will become a reserved keyword in Python 2.6
>
> it's an unknown issue only for people who has 1) never used their code
> under 2.5, or 2) never looks at the output produced by their programs.
>
> The PEP-5 process guarantees that "users will have at least a year to
> test their programs and migrate them from use of the deprecated
> construct to the alternative one," and Python 2.5 was released *two*
> years ago.
>
> So it sure looks like the SimPy folks ignored the established process.
> Why they've done that is probably a more interesting issue than the
> change itself.


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?

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

 
Reply With Quote
 
Fredrik Lundh
Guest
Posts: n/a
 
      09-22-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>

 
Reply With Quote
 
Terry Reedy
Guest
Posts: n/a
 
      09-22-2008
Fredrik Lundh wrote:
> Robert Kern wrote:


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

http://bugs.python.org/issue3936

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
James Gosling the Creator of EMACS and JAVA - leaves ORACLE - Butthen reports started coming in of odd failures. Systems would crashstrangely. We'd get crashes in applications. All applications. Crashes in thekernel. small Pox C Programming 2 07-22-2010 10:07 PM
XPath query for <?define something="something" ?> Pekka Järvinen XML 2 04-29-2008 08:12 PM
sympy: what's wrong with this picture? Mensanator Python 30 03-05-2008 10:08 PM
Help with sympy, please Dick Moores Python 11 11-19-2007 01:45 AM
umm... something... template(s)... something else... pointer(s)... and such... 0.o yah, I'm hopeless and clueless o.0 C++ 4 10-13-2004 10:34 PM



Advertisments