473,326 Members | 2,255 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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

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.
Sep 20 '08 #1
7 1442
On Sat, Sep 20, 2008 at 1:27 PM, Mensanator <me********@aol.comwrote:
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
Sep 20 '08 #2
On Sep 20, 1:34�pm, "Guilherme Polo" <ggp...@gmail.comwrote:
On Sat, Sep 20, 2008 at 1:27 PM, Mensanator <mensana...@aol.comwrote:
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 -
Sep 20 '08 #3
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>

Sep 21 '08 #4
On Sep 21, 4:37 am, Fredrik Lundh <fred...@pythonware.comwrote:
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>
Sep 21 '08 #5
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

Sep 22 '08 #6
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>

Sep 22 '08 #7
Fredrik Lundh wrote:
Robert Kern wrote:
(if someone wants to submit this to bugs.python.org, be my guest)
http://bugs.python.org/issue3936

Sep 22 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: tuka | last post by:
Hi all, I have been trying import numeric (from numpy install) and each time it crashes python.exe on windows XP. I am runing python2.4.2 and have used the original distribution and an...
1
by: Vedran Furaè | last post by:
When I call optimize.fsolve(...) python interpreter crashes immediately, no error messages, nothing, just brings me back to c:\ On linux the same code works fine. I tried it on different computers....
3
by: Jerry | last post by:
I have created an application using wxPython and compiled it using py2exe. When I put setup(console=) in my setup.py file, the resulting application runs just fine. But when I change it to...
6
by: robert | last post by:
I get python crashes and (in better cases) strange Python exceptions when (in most cases) importing and using cookielib lazy on demand in a thread. It is mainly with cookielib, but remember the...
0
by: wolfonenet | last post by:
Hi All, My setup is: WinXP Python 2.5.1 TKinter version: $Revision: 50704 $ Tcl: 8.4 Debugger: WinPdb
135
by: robinsiebler | last post by:
I've never had any call to use floating point numbers and now that I want to, I can't! *** Python 2.5.1 (r251:54863, May 1 2007, 17:47:05) on win32. *** 0.29999999999999999 0.29999999999999999
5
by: lixinyi.23 | last post by:
my code: main.cpp #include <Python.h> int main(int argc, char **argv) { Py_Initialize(); FILE *file_1 = fopen("a2l_reader.py","r+"); PyRun_SimpleFile(file_1,"a2l_reader.py");
0
by: John [H2O] | last post by:
Hello, I have a module created from a Fortran file to read in unformatted binary fortran output. It works fine for some datasets, but crashes with others. The strange thing is it will loop...
1
by: Petr Gotthard | last post by:
Hello, my C++ extension crashes under Win32 when the tp_print is called. It crashes with both Python 2.5.2 and 2.6. The crash occurs in system32\ntdll.dll, with exception code 0xc0000005. I...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.