[GRASS-dev] [GRASS GIS] #1672: gcpmanager fails to list source mapsets if non-ascii characters in grass data dir path
GRASS GIS
trac at osgeo.org
Sat Apr 6 11:48:41 PDT 2013
#1672: gcpmanager fails to list source mapsets if non-ascii characters in grass
data dir path
----------------------------------------------+-----------------------------
Reporter: hamish | Owner: grass-dev@…
Type: defect | Status: new
Priority: normal | Milestone: 6.4.3
Component: wxGUI | Version: svn-trunk
Keywords: georectifier, UnicodeDecodeError | Platform: Linux
Cpu: x86-64 |
----------------------------------------------+-----------------------------
Changes (by torsti):
* version: 6.4.2 => svn-trunk
Comment:
This one is still around (r55643). It can be traced back to
'self.grassdatabase' in '!OnLocation' (gui/wxpython/gcp/manager.py, line
376), which gets its value at line 94:
{{{
self.grassdatabase = grass.gisenv()['GISDBASE']
}}}
'gisenv' is defined at line 720 in lib/python/script/core.py:
{{{
s = read_command("g.gisenv", flags='n')
return parse_key_val(s)
}}}
Neither the string 's' read from g.gisenv nor the dictionary returned by
'parse_key_val' is explicitly decoded to Unicode, so when it is finally
implicitly cast to Unicode somewhere in Python's bowels, the default ascii
codec is used, which leads to errors if $GISDBASE contains non ascii
characters.
This a wider python (at least for < 3.x) problem, and fixing it for this
specific issue won't probably solve all existing !UnicodeDecodeErrors nor
prevent new ones from surfacing, but at least any GUI component calling
gisenv can probably be fixed at one location.
Any filenames/paths read into wxpython/pygrass should probably be
explicitly decoded to Unicode, e.g. with the 'decode()' function defined
at line 79 in script/core.py. Enforcing only ascii chars works for mapset
and location names, but can't/shouldn't be the solution for path
components not under GRASS's direct control.
--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1672#comment:2>
GRASS GIS <http://grass.osgeo.org>
More information about the grass-dev
mailing list