[GRASS-dev] [GRASS GIS] #2617: wxgui Raster query redirect to console UnicodeDecodeError
GRASS GIS
trac at osgeo.org
Wed Mar 11 07:01:53 PDT 2015
#2617: wxgui Raster query redirect to console UnicodeDecodeError
----------------------------------------------+-----------------------------
Reporter: marisn | Owner: grass-dev@…
Type: defect | Status: new
Priority: normal | Milestone: 7.0.1
Component: wxGUI | Version: svn-trunk
Keywords: query, encoding, python, gettext | Platform: MSWindows Vista
Cpu: Unspecified |
----------------------------------------------+-----------------------------
Changes (by wenzeslaus):
* keywords: query, encoding => query, encoding, python, gettext
Comment:
Replying to [comment:5 glynn]:
> Replying to [comment:4 marisn]:
>
> > In Python 2.4 the lgettext() family of functions were introduced.
The intention of these functions is to provide an alternative which is
more compliant with the current implementation of GNU gettext. Unlike
'''gettext(), which returns strings encoded with the same codeset used in
the translation file''', lgettext() will return strings encoded with the
preferred system encoding, as returned by locale.getpreferredencoding().
>
> Right. Unfortunately, gettext.install() binds the _() function to the
.gettext() method rather than to the .lgettext() method.
> Try r64834:
{{{
#!python
import gettext
gettext.install('grasslibs', os.path.join(os.getenv("GISBASE"), 'locale'))
import __builtin__
__builtin__.__dict__['_'] = __builtin__.__dict__['_'].im_self.lgettext
}}}
This solves the problem but the fix is yet another reason for me to
believe that translation function should be explicitly imported and
changing buildins, explicit or hidden, should be avoided. Compare the code
above with the code in GUI (r57219 and r57220):
{{{
#!python
# gui/wxpython/core/utils.py
# _ intended to be used also outside this module
try:
# intended to be used also outside this module
import gettext
_ = gettext.translation('grasswxpy',
os.path.join(os.getenv("GISBASE"), 'locale')).ugettext
except IOError:
# using no translation silently
def null_gettext(string):
return string
_ = null_gettext
}}}
Please see the further discussion in #2425.
--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2617#comment:7>
GRASS GIS <http://grass.osgeo.org>
More information about the grass-dev
mailing list