[GRASS-dev] [GRASS GIS] #3340: wxGUI: encoding error when saving a workspace with vector that has accents in legend_label

#3340: wxGUI: encoding error when saving a workspace with vector that has accents
in legend_label
------------------------------------+-------------------------
Reporter: mlennert | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.2.1
Component: wxGUI | Version: svn-trunk
Keywords: legend_label workspace | CPU: Unspecified
Platform: Unspecified |
------------------------------------+-------------------------
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)
}}}

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

#3340: wxGUI: encoding error when saving a workspace with vector that has accents
in legend_label
--------------------------+------------------------------------
  Reporter: mlennert | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.1
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: legend_label workspace
       CPU: Unspecified | Platform: Unspecified
--------------------------+------------------------------------

Comment (by annakrat):

In [changeset:"70979" 70979]:
{{{
#!CommitTicketReference repository="" revision="70979"
wxGUI: fix encoding, see #3340
}}}

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

#3340: wxGUI: encoding error when saving a workspace with vector that has accents
in legend_label
--------------------------+------------------------------------
  Reporter: mlennert | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.2
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: legend_label workspace
       CPU: Unspecified | Platform: Unspecified
--------------------------+------------------------------------
Changes (by annakrat):

* milestone: 7.2.1 => 7.2.2

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

#3340: wxGUI: encoding error when saving a workspace with vector that has accents
in legend_label
--------------------------+------------------------------------
  Reporter: mlennert | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.2
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: legend_label workspace
       CPU: Unspecified | Platform: Unspecified
--------------------------+------------------------------------

Comment (by mlennert):

Replying to [comment:1 annakrat]:
> In [changeset:"70979" 70979]:
> {{{
> #!CommitTicketReference repository="" revision="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 ?

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

#3340: wxGUI: encoding error when saving a workspace with vector that has accents
in legend_label
--------------------------+------------------------------------
  Reporter: mlennert | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.2
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: legend_label workspace
       CPU: Unspecified | Platform: Unspecified
--------------------------+------------------------------------

Comment (by marisn):

Replying to [comment:3 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)
}}}

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

#3340: wxGUI: encoding error when saving a workspace with vector that has accents
in legend_label
--------------------------+------------------------------------
  Reporter: mlennert | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.2
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: legend_label workspace
       CPU: Unspecified | Platform: Unspecified
--------------------------+------------------------------------
Changes (by marisn):

* Attachment "rm_enctest.gxw" added.

Encoding test for workspace loading

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

#3340: wxGUI: encoding error when saving a workspace with vector that has accents
in legend_label
--------------------------+------------------------------------
  Reporter: mlennert | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.2
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: legend_label workspace
       CPU: Unspecified | Platform: Unspecified
--------------------------+------------------------------------

Comment (by annakrat):

In [changeset:"70985" 70985]:
{{{
#!CommitTicketReference repository="" revision="70985"
wxGUI: fix encoding problems, see #3340
}}}

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

#3340: wxGUI: encoding error when saving a workspace with vector that has accents
in legend_label
--------------------------+------------------------------------
  Reporter: mlennert | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.2
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: legend_label workspace
       CPU: Unspecified | Platform: Unspecified
--------------------------+------------------------------------

Comment (by marisn):

Replying to [comment:5 annakrat]:
> In [changeset:"70985" 70985]:
> {{{
> #!CommitTicketReference repository="" revision="70985"
> wxGUI: fix encoding problems, see #3340
> }}}
Now saving and loading seems to work fine. I think it has also fixed
#3275.

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

#3340: wxGUI: encoding error when saving a workspace with vector that has accents
in legend_label
--------------------------+------------------------------------
  Reporter: mlennert | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.2
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: legend_label workspace
       CPU: Unspecified | Platform: Unspecified
--------------------------+------------------------------------

Comment (by annakrat):

Replying to [comment:3 mlennert]:
> Replying to [comment:1 annakrat]:
> > In [changeset:"70979" 70979]:
> > {{{
> > #!CommitTicketReference repository="" revision="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.

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

#3340: wxGUI: encoding error when saving a workspace with vector that has accents
in legend_label
--------------------------+------------------------------------
  Reporter: mlennert | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.2
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: legend_label workspace
       CPU: Unspecified | Platform: Unspecified
--------------------------+------------------------------------

Comment (by mlennert):

Replying to [comment:7 annakrat]:
> Replying to [comment:3 mlennert]:
> > Replying to [comment:1 annakrat]:
> > > In [changeset:"70979" 70979]:
> > > {{{
> > > #!CommitTicketReference repository="" revision="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.

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

#3340: wxGUI: encoding error when saving a workspace with vector that has accents
in legend_label
--------------------------+------------------------------------
  Reporter: mlennert | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.2
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: legend_label workspace
       CPU: Unspecified | Platform: Unspecified
--------------------------+------------------------------------

Comment (by mlennert):

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

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

#3340: wxGUI: encoding error when saving a workspace with vector that has accents
in legend_label
--------------------------+------------------------------------
  Reporter: mlennert | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.2.2
Component: wxGUI | Version: svn-trunk
Resolution: fixed | Keywords: legend_label workspace
       CPU: Unspecified | Platform: Unspecified
--------------------------+------------------------------------
Changes (by annakrat):

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

Comment:

Backported in r71057.

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