[GRASS-dev] [GRASS GIS] #2552: GRASS 7.0 RC1 wxGUI: fails to launch in Spanish locale (UnicodeEncodeError)

#2552: GRASS 7.0 RC1 wxGUI: fails to launch in Spanish locale (UnicodeEncodeError)
------------------------+---------------------------------------------------
Reporter: santipardo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-releasebranch70
Keywords: | Platform: Linux
      Cpu: x86-64 |
------------------------+---------------------------------------------------
With Spanish locale (es_ES.UTF-8), GRASS 7.0 RC1 doesn't launch. I have
launched it perfectly in the same installation with locale en_US-UTF-8.
The problem is happening since beta 4.0.

CONF:

{{{
Linux Mint 17.1
$ locale | grep LANG
LANG=es_ES.UTF-8
}}}

TERMINAL OUTPUT:

{{{
Launching <wxpython> GUI in the background, please wait...
Traceback (most recent call last):
   File "/usr/bin/grass70", line 1461, in <module>
     bash_startup()
   File "/usr/bin/grass70", line 1122, in bash_startup
     _("3D raster MASK present")))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xc1' in
position 180: ordinal not in range(128)
ERROR: Variable 'LOCATION_NAME' not set
Traceback (most recent call last):
   File "/usr/lib/grass70/gui/wxpython/wxgui.py", line 37, in <module>
     from lmgr.frame import GMFrame
   File "/usr/lib/grass70/gui/wxpython/lmgr/frame.py", line 50, in <module>
     from lmgr.layertree import LayerTree, LMIcons
   File "/usr/lib/grass70/gui/wxpython/lmgr/layertree.py", line 37, in
<module>
     from mapdisp.frame import MapFrame
   File "/usr/lib/grass70/gui/wxpython/mapdisp/frame.py", line 65, in
<module>
     class MapFrame(SingleMapFrame):
   File "/usr/lib/grass70/gui/wxpython/mapdisp/frame.py", line 71, in
MapFrame
     page = None, Map = Map(), auimgr = None, name = 'MapWindow',
**kwargs):
   File "/usr/lib/grass70/gui/wxpython/core/render.py", line 408, in
__init__
     self.mapfile = grass.tempfile(create = False) + '.ppm'
   File "/usr/lib/grass70/etc/python/grass/script/core.py", line 704, in
tempfile
     return read_command("g.tempfile", flags=flags,
pid=os.getpid()).strip()
   File "/usr/lib/grass70/etc/python/grass/script/core.py", line 427, in
read_command
     return handle_errors(returncode, stdout, args, kwargs)
   File "/usr/lib/grass70/etc/python/grass/script/core.py", line 310, in
handle_errors
     returncode=returncode)
grass.exceptions.CalledModuleError: Module run None ['g.tempfile', '-d',
'pid=2237'] ended with error
Process ended with non-zero return code 1. See errors in the (error)
output.
}}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2552&gt;
GRASS GIS <http://grass.osgeo.org>

#2552: GRASS 7.0 RC1 wxGUI: fails to launch in Spanish locale (UnicodeEncodeError)
------------------------+---------------------------------------------------
Reporter: santipardo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 7.0.0
Component: wxGUI | Version: svn-releasebranch70
Keywords: locale | Platform: Linux
      Cpu: x86-64 |
------------------------+---------------------------------------------------
Changes (by martinl):

  * keywords: => locale
  * priority: normal => blocker

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2552#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#2552: GRASS 7.0 RC1 wxGUI: fails to launch in Spanish locale (UnicodeEncodeError)
------------------------+---------------------------------------------------
Reporter: santipardo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 7.0.0
Component: wxGUI | Version: svn-releasebranch70
Keywords: locale | Platform: Linux
      Cpu: x86-64 |
------------------------+---------------------------------------------------

Comment(by annakrat):

I encoded the string in r64335 to the encoding set during the startup. I
am not sure if that solves the problem, needs testing.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2552#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#2552: GRASS 7.0 RC1 wxGUI: fails to launch in Spanish locale (UnicodeEncodeError)
------------------------+---------------------------------------------------
Reporter: santipardo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 7.0.0
Component: wxGUI | Version: svn-releasebranch70
Keywords: locale | Platform: Linux
      Cpu: x86-64 |
------------------------+---------------------------------------------------

Comment(by santipardo):

I am afraid the problem is yet there...

{{{
Launching <wxpython> GUI in the background, please wait...
Traceback (most recent call last):
   File "/usr/local/bin/grass70", line 1475, in <module>
     bash_startup()
   File "/usr/local/bin/grass70", line 1141, in bash_startup
     _("3D raster MASK present"))).encode(encoding))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 176:
ordinal not in range(128)
}}}

(Working again perfectly with locale en_US.UTF-8)

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2552#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#2552: GRASS 7.0 RC1 wxGUI: fails to launch in Spanish locale (UnicodeEncodeError)
------------------------+---------------------------------------------------
Reporter: santipardo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 7.0.0
Component: wxGUI | Version: svn-releasebranch70
Keywords: locale | Platform: Linux
      Cpu: x86-64 |
------------------------+---------------------------------------------------

Comment(by annakrat):

I changed it only in trunk (grass71). Can you test it there?

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2552#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#2552: GRASS 7.0 RC1 wxGUI: fails to launch in Spanish locale (UnicodeEncodeError)
------------------------+---------------------------------------------------
Reporter: santipardo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 7.0.0
Component: wxGUI | Version: svn-releasebranch70
Keywords: locale | Platform: Linux
      Cpu: x86-64 |
------------------------+---------------------------------------------------

Comment(by santipardo):

Replying to [comment:4 annakrat]:
> I changed it only in trunk (grass71). Can you test it there?

Tested after compiling from trunk:

{{{
svn co https://svn.osgeo.org/grass/grass/trunk
Revisión obtenida: 64343
}}}

And not working:

{{{
Launching <wxpython> GUI in the background, please wait...
Traceback (most recent call last):
   File "./grass71", line 1475, in <module>
     bash_startup()
   File "./grass71", line 1141, in bash_startup
     _("3D raster MASK present"))).encode(encoding))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 176:
ordinal not in range(128)
ERROR: Variable 'LOCATION_NAME' not set
Unable to get GRASS version
GRASS_INFO_ERROR(29548,1): Variable 'LOCATION_NAME' not set
GRASS_INFO_END(29548,1)
}}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2552#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>

#2552: GRASS 7.0 RC1 wxGUI: fails to launch in Spanish locale (UnicodeEncodeError)
------------------------+---------------------------------------------------
Reporter: santipardo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 7.0.0
Component: wxGUI | Version: svn-releasebranch70
Keywords: locale | Platform: Linux
      Cpu: x86-64 |
------------------------+---------------------------------------------------

Comment(by glynn):

Replying to [comment:2 annakrat]:
> I encoded the string in r64335 to the encoding set during the startup. I
am not sure if that solves the problem, needs testing.
That change is bogus. The string should be a str (byte string), not
unicode, so calling .encode() on it is meaningless. Reverted in r64364.

The error appears to arise from r41856 passing unicode=True to
gettext.install(), meaning that translated strings are returned as unicode
values which then end up being converted to strings using the default
encoding. Fixed in r64366.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2552#comment:6&gt;
GRASS GIS <http://grass.osgeo.org>

#2552: GRASS 7.0 RC1 wxGUI: fails to launch in Spanish locale (UnicodeEncodeError)
------------------------+---------------------------------------------------
Reporter: santipardo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 7.0.0
Component: wxGUI | Version: svn-releasebranch70
Keywords: locale | Platform: Linux
      Cpu: x86-64 |
------------------------+---------------------------------------------------

Comment(by glynn):

Replying to [comment:6 glynn]:

> The error appears to arise from r41856 passing unicode=True to
gettext.install()

A similar mistake exists in r59652, fixed in r64367

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2552#comment:7&gt;
GRASS GIS <http://grass.osgeo.org>

#2552: GRASS 7.0 RC1 wxGUI: fails to launch in Spanish locale (UnicodeEncodeError)
-------------------------+--------------------------------------------------
  Reporter: santipardo | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: blocker | Milestone: 7.0.0
Component: wxGUI | Version: svn-releasebranch70
Resolution: fixed | Keywords: locale
  Platform: Linux | Cpu: x86-64
-------------------------+--------------------------------------------------
Changes (by santipardo):

  * status: new => closed
  * resolution: => fixed

Comment:

Now the GUI opens and it's perfectly working in locale Spanish. Thanks!!!

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2552#comment:8&gt;
GRASS GIS <http://grass.osgeo.org>

#2552: GRASS 7.0 RC1 wxGUI: fails to launch in Spanish locale (UnicodeEncodeError)
-------------------------+--------------------------------------------------
  Reporter: santipardo | Owner: grass-dev@…
      Type: defect | Status: reopened
  Priority: blocker | Milestone: 7.0.0
Component: wxGUI | Version: svn-releasebranch70
Resolution: | Keywords: locale
  Platform: Linux | Cpu: x86-64
-------------------------+--------------------------------------------------
Changes (by martinl):

  * status: closed => reopened
  * resolution: fixed =>

Comment:

Reopening the ticket because it needs to be backported to `relbr70` before
closing.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2552#comment:9&gt;
GRASS GIS <http://grass.osgeo.org>

#2552: GRASS 7.0 RC1 wxGUI: fails to launch in Spanish locale (UnicodeEncodeError)
-------------------------+--------------------------------------------------
  Reporter: santipardo | Owner: grass-dev@…
      Type: defect | Status: reopened
  Priority: blocker | Milestone: 7.0.0
Component: wxGUI | Version: svn-releasebranch70
Resolution: | Keywords: locale
  Platform: Linux | Cpu: x86-64
-------------------------+--------------------------------------------------

Comment(by martinl):

Replying to [comment:9 martinl]:
> Reopening the ticket because it needs to be backported to `relbr70`
before closing.

I tried to backport r64367 to `relbr70` in r64369. Unfortunately
`grass.py` in trunk differs from relbr70 too much regarding language
settings. Does anybody know more about that? I hesitate to backport the
diff completely in hard freeze.

Anyway, please, could you try also recent GRASS 70 release branch? It
should have been fixed there too.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2552#comment:10&gt;
GRASS GIS <http://grass.osgeo.org>

#2552: GRASS 7.0 RC1 wxGUI: fails to launch in Spanish locale (UnicodeEncodeError)
-------------------------+--------------------------------------------------
  Reporter: santipardo | Owner: grass-dev@…
      Type: defect | Status: reopened
  Priority: blocker | Milestone: 7.0.0
Component: wxGUI | Version: svn-releasebranch70
Resolution: | Keywords: locale
  Platform: Linux | Cpu: x86-64
-------------------------+--------------------------------------------------

Comment(by santipardo):

Not working yet after compiling release branch r64369:

{{{
Welcome to GRASS GIS 7.0.0svn (r64369)

Launching <wxpython> GUI in the background, please wait...
Traceback (most recent call last):
   File "./grass70", line 1462, in <module>
     bash_startup()
   File "./grass70", line 1122, in bash_startup
     _("3D raster MASK present")))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xc1' in
position 176: ordinal not in range(128)
}}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2552#comment:11&gt;
GRASS GIS <http://grass.osgeo.org>

#2552: GRASS 7.0 RC1 wxGUI: fails to launch in Spanish locale (UnicodeEncodeError)
-------------------------+--------------------------------------------------
  Reporter: santipardo | Owner: grass-dev@…
      Type: defect | Status: reopened
  Priority: blocker | Milestone: 7.0.0
Component: wxGUI | Version: svn-releasebranch70
Resolution: | Keywords: locale
  Platform: Linux | Cpu: x86-64
-------------------------+--------------------------------------------------

Comment(by martinl):

Replying to [comment:11 santipardo]:
> Not working yet after compiling release branch r64369:

OK, I took liberty to sync `set_language()` functions with try. Please try
out r64370.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2552#comment:12&gt;
GRASS GIS <http://grass.osgeo.org>

#2552: GRASS 7.0 RC1 wxGUI: fails to launch in Spanish locale (UnicodeEncodeError)
-------------------------+--------------------------------------------------
  Reporter: santipardo | Owner: grass-dev@…
      Type: defect | Status: reopened
  Priority: blocker | Milestone: 7.0.0
Component: wxGUI | Version: svn-releasebranch70
Resolution: | Keywords: locale
  Platform: Linux | Cpu: x86-64
-------------------------+--------------------------------------------------

Comment(by santipardo):

Recompiled from r64370 and working now. The /etc/VERSIONNUMBER doesn't
update, it remains "7.0.0svn r64369" (I don't know if there's a little bug
here, or it's only a problem in my system).

But it works!

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2552#comment:13&gt;
GRASS GIS <http://grass.osgeo.org>

#2552: GRASS 7.0 RC1 wxGUI: fails to launch in Spanish locale (UnicodeEncodeError)
-------------------------+--------------------------------------------------
  Reporter: santipardo | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: blocker | Milestone: 7.0.0
Component: wxGUI | Version: svn-releasebranch70
Resolution: fixed | Keywords: locale
  Platform: Linux | Cpu: x86-64
-------------------------+--------------------------------------------------
Changes (by martinl):

  * status: reopened => closed
  * resolution: => fixed

Comment:

Replying to [comment:13 santipardo]:
> Recompiled from r64370 and working now. The /etc/VERSIONNUMBER doesn't
update, it remains "7.0.0svn r64369" (I don't know if there's a little bug
here, or it's only a problem in my system).

you need to run `configure` script to update revision number.

> But it works!

Thanks for testing, closing ticket.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2552#comment:14&gt;
GRASS GIS <http://grass.osgeo.org>