cmweiss / geomag

Automatically exported from code.google.com/p/geomag
45 stars 43 forks source link

bad syntax in geomag.py??: open(wmm_filename) as wmm_file: #1

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 9 years ago
I'm getting the following error:

[error] [client 67.161.206.12]File "[***]/geomag.py", line 200, referer: 
http://[...].cgi
[error] [client 67.161.206.12]     with open(wmm_filename) as wmm_file:, 
referer: http://[...].cgi
[error] [client 67.161.206.12]             ^, referer: http://[...].cgi
[error] [client 67.161.206.12] SyntaxError: invalid syntax, referer: 
http://[...].cgi

I'm using python 2.5.2 on a linux server hosted by dreamhost.

I don't know enough to know why that line would be flagged as bad syntax.

----
Lines in my script are:

    from geomag import geomag
    [...]
    gm = geomag.GeoMag("geomag/WMM.COF")
    mag = gm.GeoMag(lat, lon)

----
I couldn't use setup.py because on dreamhost I don't have all the write 
permissions the script wanted.  I have geomag in a directory in the same 
directory as my script, a setup which works fine in an identical script and 
setup on my local machine (a mac running OSX 10.6, with python 2.6.1).

Original issue reported on code.google.com by krobin...@gmail.com on 15 Oct 2010 at 1:17

GoogleCodeExporter commented 9 years ago
I replaced the with open... line with:

    wmm_file = open(wmm_filename,"rb")
        if (1):

and the module seems to work now.

Original comment by krobin...@gmail.com on 15 Oct 2010 at 3:10

GoogleCodeExporter commented 9 years ago
I haven't looked at this in 5 years. My guess is that this is a 2.5 vs. 2.6 
issue with respect to the syntax of open(). I'll investigate.

Original comment by cmwe...@gmail.com on 19 Dec 2014 at 4:45

GoogleCodeExporter commented 9 years ago
The documentation for 2.5 indicates that the mode parameter is optional and 
that the default is "r" for read only (read only text mode on windows and mac). 
Since the .COF file is ascii text the "rb" (read binary) mode should not be 
correct.
See: 
https://docs.python.org/release/2.5/tut/node9.html#SECTION009200000000000000000
I'll continue to investigate to see if the "rb" mode could be harmful.

Original comment by cmwe...@gmail.com on 19 Dec 2014 at 4:59

cmweiss commented 8 years ago

Not fixing. Cannot reproduce.