[GRASS-dev] wxgui encoding issues

Moritz Lennert mlennert at club.worldonline.be
Mon Nov 19 08:37:22 PST 2012


On 08/11/12 13:42, Moritz Lennert wrote:
> - Trying to save any model from the graphical modeller, even a
> completely empty one gives me:
>
> Traceback (most recent call last):
> File
> "/home/mlennert/SRC/GRASS/grass_trunk/dist.i686-pc-linux-gnu/etc/gui/wxpython/gmodeler/frame.py",
> line 868, in WriteModelFile
> WriteModelFile(fd = tmpfile, model = self.model)
> File
> "/home/mlennert/SRC/GRASS/grass_trunk/dist.i686-pc-linux-gnu/etc/gui/wxpython/gmodeler/model.py",
> line 1758, in __init__
> self._properties()
> File
> "/home/mlennert/SRC/GRASS/grass_trunk/dist.i686-pc-linux-gnu/etc/gui/wxpython/gmodeler/model.py",
> line 1807, in _properties
> self.fd.write('%s<name>%s</name>\n' % (' ' * self.indent,
> self.properties['name']))
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in
> position 17: ordinal not in range(128)
>
> This second issue seems to come from line 58 in
> gui/wxpython/gmodele/model.py :
>
> self.properties = { 'name' : _("model"),
>
> Does this property really have to be translatable ? If I change line
> 1807 mentioned in the traceback to
>
> self.fd.write('%s<name>%s</name>\n' % (' ' * self.indent,
> self.properties['name'].encode('UTF-8')))
>
> it works. What I don't understand is that I don't have to do this for
> the description in the next line which also contains an accent in French.
>

I see an attempts at solving this in r52329 (and consequent merges in 
other branches):

@@ -2001,9 +2001,11 @@
  # DATE:         %s
  #
-############################################################################# 

-""" % (properties['name'],
-       properties['author'],
-       properties['description'],
-       time.asctime()))
+#%s
+""" % ('#' * 79,
+       properties['name'],
+       EncodeString(properties['author']),
+       EncodeString('\n# '.join(properties['description'].splitlines())),
+       time.asctime(),
+       '#' * 79))

          self.fd.write(

Any reason why you do not encode 'name' ? This also causes an error.

Moritz


More information about the grass-dev mailing list