Opened 9 years ago

Closed 9 years ago

#2552 closed defect (fixed)

GRASS 7.0 RC1 wxGUI: fails to launch in Spanish locale (UnicodeEncodeError)

Reported by: santipardo Owned by: grass-dev@…
Priority: blocker Milestone: 7.0.0
Component: wxGUI Version: svn-releasebranch70
Keywords: locale Cc:
CPU: x86-64 Platform: Linux

Description

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.

Change History (14)

comment:1 by martinl, 9 years ago

Keywords: locale added
Priority: normalblocker

comment:2 by annakrat, 9 years ago

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

comment:3 by santipardo, 9 years ago

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)

comment:4 by annakrat, 9 years ago

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

in reply to:  4 comment:5 by santipardo, 9 years ago

Replying to 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)

in reply to:  2 ; comment:6 by glynn, 9 years ago

Replying to 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.

in reply to:  6 comment:7 by glynn, 9 years ago

Replying to glynn:

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

A similar mistake exists in r59652, fixed in r64367

comment:8 by santipardo, 9 years ago

Resolution: fixed
Status: newclosed

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

comment:9 by martinl, 9 years ago

Resolution: fixed
Status: closedreopened

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

in reply to:  9 comment:10 by martinl, 9 years ago

Replying to 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.

comment:11 by santipardo, 9 years ago

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)

in reply to:  11 comment:12 by martinl, 9 years ago

Replying to santipardo:

Not working yet after compiling release branch r64369:

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

comment:13 by santipardo, 9 years ago

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!

in reply to:  13 comment:14 by martinl, 9 years ago

Resolution: fixed
Status: reopenedclosed

Replying to 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.

Note: See TracTickets for help on using tickets.