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

Glynn Clements glynn at gclements.plus.com
Mon Oct 12 15:07:41 EDT 2009


[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 at 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 at gclements.plus.com>


More information about the grass-dev mailing list