[GRASS-dev] Re: [GRASS-user] grass-6.4.0RC5 and wx-python

[CC to grass-dev]

Alfredo Alessandrini wrote:

I've compiled grass-6.4.0RC5 with wx-python, but I've this problem
when I start it:

alfredo@astore:~$ grass64 -wx
Cleaning up temporary files ...
Starting GRASS ...
Traceback (most recent call last):
  File "/usr/local/grass-6.4.0RC5/etc/wxpython/gis_set.py", line 33, in <module>
    from gui_modules import globalvar
  File "/usr/local/grass-6.4.0RC5/etc/wxpython/gui_modules/globalvar.py",
line 55, in <module>
    CheckForWx()
  File "/usr/local/grass-6.4.0RC5/etc/wxpython/gui_modules/globalvar.py",
line 44, in CheckForWx
    except (ImportError, ValueError, wxversion.VersionError), e:
UnboundLocalError: local variable 'wxversion' referenced before assignment

I'm sure that this has been reported before, but I can't find anything
in Trac.

The problem is that the code tries to handle failing to import
wxversion and wxversion-specific exceptions using the same "try"
block:

    try:
        import wxversion
        wxversion.select(str(minVersion[0]) + '.' + str(minVersion[1]))
        ...

    except (ImportError, ValueError, wxversion.VersionError), e:
        ...

Obviously, if the "import wxversion" fails, wxversion.VersionError
isn't going to resolve.

FWIW, the same problem exists in trunk.

The code should probably look something like:

    try:
        import wxversion
        try:
            wxversion.select(str(minVersion[0]) + '.' + str(minVersion[1]))
            ...
        except (ValueError, wxversion.VersionError), e:
            ...

    except ImportError, e:
        ...

--
Glynn Clements <glynn@gclements.plus.com>

Hi,

2009/10/12 Glynn Clements <glynn@gclements.plus.com>:

Obviously, if the "import wxversion" fails, wxversion.VersionError
isn't going to resolve.

FWIW, the same problem exists in trunk.

The code should probably look something like:

try:
import wxversion
try:
wxversion.select(str(minVersion[0]) + '.' + str(minVersion[1]))
...
except (ValueError, wxversion.VersionError), e:
...

except ImportError, e:

right, hopefully fixed r39494.

Martin

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa