Opened 8 years ago

Closed 8 years ago

#3340 closed defect (fixed)

wxGUI: encoding error when saving a workspace with vector that has accents in legend_label

Reported by: mlennert Owned by: grass-dev@…
Priority: normal Milestone: 7.2.2
Component: wxGUI Version: svn-trunk
Keywords: legend_label workspace Cc:
CPU: Unspecified Platform: Unspecified

Description

Whenever I have a vector map with a legend_label with accents, such as:

d.vect map=roadsmajor@PERMANENT type=point,line,boundary,area,face width=1 legend_label=Chaussées

I cannot save the workspace file because of an encoding error:

Échec d'écriture des paramètres de l'espace de travail courant.

Raison: 'ascii' codec can't encode character u'\xe9' in position 33: ordinal not in range(128)

Traceback (most recent call last):
  File "/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-gnu/gui/wxpython/lmgr/frame.py", line 1649, in SaveToWorkspaceFile
    WriteWorkspaceFile(lmgr=self, file=tmpfile)
  File "/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-gnu/gui/wxpython/core/workspace.py", line 900, in __init__
    self.__writeLayer(mapTree, item)
  File "/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-gnu/gui/wxpython/core/workspace.py", line 993, in __writeLayer
    (' ' * self.indent, self.__filterValue(val)))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 33: ordinal not in range(128)

Attachments (1)

rm_enctest.gxw (2.8 KB ) - added by marisn 8 years ago.
Encoding test for workspace loading

Download all attachments as: .zip

Change History (11)

comment:1 by annakrat, 8 years ago

In 70979:

wxGUI: fix encoding, see #3340

comment:2 by annakrat, 8 years ago

Milestone: 7.2.17.2.2

in reply to:  1 ; comment:3 by mlennert, 8 years ago

Replying to annakrat:

In 70979:

wxGUI: fix encoding, see #3340

Works great. Thanks for the quick fix !

You changed the milestone to 7.2.2. I had the feeling that this is a quite small and pretty non-invasive fix of a standard bug. Don't you think it could still go into 7.2.1 ?

in reply to:  3 comment:4 by marisn, 8 years ago

Replying to mlennert:

Works great. Thanks for the quick fix !

Sort of. Related issue seems to be #3275 I tested various text elements and managed to save workspace just fine, still loading fails, although the error might come form a different area (I'll attach file for testing):

Traceback (most recent call last):
  File "dist.x86_64-pc-linux-gnu/gui/wxpython/lmgr/frame.py", line 1362, in
OnWorkspaceOpen

self.LoadWorkspaceFile(filename)
  File "dist.x86_64-pc-linux-gnu/gui/wxpython/lmgr/frame.py", line 1512, in
LoadWorkspaceFile

mapdisplay[i].AddBarscale(overlay['cmd'])
  File "dist.x86_64-pc-linux-gnu/gui/wxpython/mapdisp/frame.py", line 1224, in
AddBarscale

cmd, completed=(self.GetOptData, None, None))
  File "dist.x86_64-pc-linux-gnu/gui/wxpython/gui_core/forms.py", line 2890, in
ParseCommand

get_dcmd=get_dcmd, layer=layer)
  File "dist.x86_64-pc-linux-gnu/gui/wxpython/gui_core/forms.py", line 534, in __init__

frame=self)
  File "dist.x86_64-pc-linux-gnu/gui/wxpython/gui_core/forms.py", line 1313, in __init__

win.SetValue(str(value))
UnicodeEncodeError
:
'ascii' codec can't encode characters in position 0-6:
ordinal not in range(128)

by marisn, 8 years ago

Attachment: rm_enctest.gxw added

Encoding test for workspace loading

comment:5 by annakrat, 8 years ago

In 70985:

wxGUI: fix encoding problems, see #3340

in reply to:  5 comment:6 by marisn, 8 years ago

Replying to annakrat:

In 70985:

wxGUI: fix encoding problems, see #3340

Now saving and loading seems to work fine. I think it has also fixed #3275.

in reply to:  3 ; comment:7 by annakrat, 8 years ago

Replying to mlennert:

Replying to annakrat:

In 70979:

wxGUI: fix encoding, see #3340

Works great. Thanks for the quick fix !

You changed the milestone to 7.2.2. I had the feeling that this is a quite small and pretty non-invasive fix of a standard bug. Don't you think it could still go into 7.2.1 ?

Too close right now, I wouldn't be comfortable doing that especially because I haven't tested it on Windows.

in reply to:  7 comment:8 by mlennert, 8 years ago

Replying to annakrat:

Replying to mlennert:

Replying to annakrat:

In 70979:

wxGUI: fix encoding, see #3340

Works great. Thanks for the quick fix !

You changed the milestone to 7.2.2. I had the feeling that this is a quite small and pretty non-invasive fix of a standard bug. Don't you think it could still go into 7.2.1 ?

Too close right now, I wouldn't be comfortable doing that especially because I haven't tested it on Windows.

Ok. I agree. So we'll leave this open as a reminder for backport.

comment:9 by mlennert, 8 years ago

Is there some documentation about best practices in GUI programming concerning handling of encoding ?

comment:10 by annakrat, 8 years ago

Resolution: fixed
Status: newclosed

Backported in r71057.

Note: See TracTickets for help on using tickets.