[GRASS-dev] [GRASS GIS] #4017: run addon failed > name 'unicode' is not defined

#4017: run addon failed > name 'unicode' is not defined
---------------------+---------------------------------
Reporter: 1266 | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone:
Component: Default | Version: git-releasebranch78
Keywords: | CPU: x86-64
Platform: Linux |
---------------------+---------------------------------
After installing grass 7.8.3 on debian buster my python2 scripts does not
work anymore. Error message :
Traceback (most recent call last):
   File "/usr/local/grass78/gui/wxpython/gui_core/forms.py",
line 2866, in ParseCommand

blackList=_blackList)
   File "/usr/local/grass78/etc/python/grass/script/task.py",
line 522, in parse_interface

tree = etree.fromstring(get_interface_description(name))
   File "/usr/local/grass78/etc/python/grass/script/task.py",
line 498, in get_interface_description

"\n\nDetails: <{det}>").format(cmd=cmd, det=decode(cmderr)))
grass.exceptions
.
ScriptError
:
Unable to fetch interface description for command
'<r.wtg.visibility>'.
Details: <Traceback (most recent call last):
   File
"/home/frank/.grass7/addons/scripts/r.wtg.visibility", line
299, in <module>
     from grass.pygrass.utils import set_path
   File
"/usr/local/grass78/etc/python/grass/pygrass/utils.py", line
7, in <module>
     import grass.lib.gis as libgis
   File "/usr/local/grass78/etc/python/grass/lib/gis.py",
line 4
SyntaxError: Non-ASCII character '\xc3' in file
/usr/local/grass78/etc/python/grass/lib/gis.py on line 5,
but no encoding declared; see
http://python.org/dev/peps/pep-0263/ for details
>
During handling of the above exception, another exception
occurred:
Traceback (most recent call last):
   File "/usr/local/grass78/gui/wxpython/core/gconsole.py",
line 493, in RunCmd

task = GUI(show=None).ParseCommand(command)
   File "/usr/local/grass78/gui/wxpython/gui_core/forms.py",
line 2868, in ParseCommand

raise gcmd.GException(e.value)
core.gcmd
.
GException
:
Unable to fetch interface description for command
'<r.wtg.visibility>'.
Details: <Traceback (most recent call last):
   File
"/home/frank/.grass7/addons/scripts/r.wtg.visibility", line
299, in <module>
     from grass.pygrass.utils import set_path
   File
"/usr/local/grass78/etc/python/grass/pygrass/utils.py", line
7, in <module>
     import grass.lib.gis as libgis
   File "/usr/local/grass78/etc/python/grass/lib/gis.py",
line 4
SyntaxError: Non-ASCII character '\xc3' in file
/usr/local/grass78/etc/python/grass/lib/gis.py on line 5,
but no encoding declared; see
http://python.org/dev/peps/pep-0263/ for details
>
During handling of the above exception, another exception
occurred:
Traceback (most recent call last):
   File "/usr/local/grass78/gui/wxpython/gui_core/prompt.py",
line 413, in OnKeyPressed

self._runCmd(self.GetCurLine()[0].strip())
   File "/usr/local/grass78/gui/wxpython/gui_core/prompt.py",
line 120, in _runCmd

self.promptRunCmd.emit(cmd=cmd)
   File
"/usr/local/grass78/etc/python/grass/pydispatch/signal.py",
line 229, in emit

dispatcher.send(signal=self, *args, **kwargs)
   File "/usr/local/grass78/etc/python/grass/pydispatch/dispa
tcher.py", line 349, in send

**named
   File "/usr/local/grass78/etc/python/grass/pydispatch/robus
tapply.py", line 60, in robustApply

return receiver(*arguments, **named)
   File
"/usr/local/grass78/gui/wxpython/gui_core/goutput.py", line
120, in <lambda>

self._gconsole.RunCmd(command=cmd))
   File "/usr/local/grass78/gui/wxpython/core/gconsole.py",
line 496, in RunCmd

message=unicode(e),
NameError
:
name 'unicode' is not defined

----------------------
If I add # -*- coding:UTF-8 -*- on first line in
/usr/local/grass78/etc/python/grass/lib/gis.py and
/usr/local/grass78/etc/python/grass/lib/raster.py my scripts seem to work
(gui dispalyed)

my LOCAL is LANG=fr_FR.UTF-8

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

#4017: run addon failed > name 'unicode' is not defined
---------------------+---------------------------------
  Reporter: 1266 | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.8.3
Component: wxGUI | Version: git-releasebranch78
Resolution: | Keywords: python3
       CPU: x86-64 | Platform: Linux
---------------------+---------------------------------
Changes (by neteler):

* keywords: => python3
* component: Default => wxGUI
* milestone: => 7.8.3

Old description:

After installing grass 7.8.3 on debian buster my python2 scripts does not
work anymore. Error message :
Traceback (most recent call last):
  File "/usr/local/grass78/gui/wxpython/gui_core/forms.py",
line 2866, in ParseCommand

blackList=_blackList)
  File "/usr/local/grass78/etc/python/grass/script/task.py",
line 522, in parse_interface

tree = etree.fromstring(get_interface_description(name))
  File "/usr/local/grass78/etc/python/grass/script/task.py",
line 498, in get_interface_description

"\n\nDetails: <{det}>").format(cmd=cmd, det=decode(cmderr)))
grass.exceptions
.
ScriptError
:
Unable to fetch interface description for command
'<r.wtg.visibility>'.
Details: <Traceback (most recent call last):
  File
"/home/frank/.grass7/addons/scripts/r.wtg.visibility", line
299, in <module>
    from grass.pygrass.utils import set_path
  File
"/usr/local/grass78/etc/python/grass/pygrass/utils.py", line
7, in <module>
    import grass.lib.gis as libgis
  File "/usr/local/grass78/etc/python/grass/lib/gis.py",
line 4
SyntaxError: Non-ASCII character '\xc3' in file
/usr/local/grass78/etc/python/grass/lib/gis.py on line 5,
but no encoding declared; see
http://python.org/dev/peps/pep-0263/ for details
>
During handling of the above exception, another exception
occurred:
Traceback (most recent call last):
  File "/usr/local/grass78/gui/wxpython/core/gconsole.py",
line 493, in RunCmd

task = GUI(show=None).ParseCommand(command)
  File "/usr/local/grass78/gui/wxpython/gui_core/forms.py",
line 2868, in ParseCommand

raise gcmd.GException(e.value)
core.gcmd
.
GException
:
Unable to fetch interface description for command
'<r.wtg.visibility>'.
Details: <Traceback (most recent call last):
  File
"/home/frank/.grass7/addons/scripts/r.wtg.visibility", line
299, in <module>
    from grass.pygrass.utils import set_path
  File
"/usr/local/grass78/etc/python/grass/pygrass/utils.py", line
7, in <module>
    import grass.lib.gis as libgis
  File "/usr/local/grass78/etc/python/grass/lib/gis.py",
line 4
SyntaxError: Non-ASCII character '\xc3' in file
/usr/local/grass78/etc/python/grass/lib/gis.py on line 5,
but no encoding declared; see
http://python.org/dev/peps/pep-0263/ for details
>
During handling of the above exception, another exception
occurred:
Traceback (most recent call last):
  File "/usr/local/grass78/gui/wxpython/gui_core/prompt.py",
line 413, in OnKeyPressed

self._runCmd(self.GetCurLine()[0].strip())
  File "/usr/local/grass78/gui/wxpython/gui_core/prompt.py",
line 120, in _runCmd

self.promptRunCmd.emit(cmd=cmd)
  File
"/usr/local/grass78/etc/python/grass/pydispatch/signal.py",
line 229, in emit

dispatcher.send(signal=self, *args, **kwargs)
  File "/usr/local/grass78/etc/python/grass/pydispatch/dispa
tcher.py", line 349, in send

**named
  File "/usr/local/grass78/etc/python/grass/pydispatch/robus
tapply.py", line 60, in robustApply

return receiver(*arguments, **named)
  File
"/usr/local/grass78/gui/wxpython/gui_core/goutput.py", line
120, in <lambda>

self._gconsole.RunCmd(command=cmd))
  File "/usr/local/grass78/gui/wxpython/core/gconsole.py",
line 496, in RunCmd

message=unicode(e),
NameError
:
name 'unicode' is not defined

----------------------
If I add # -*- coding:UTF-8 -*- on first line in
/usr/local/grass78/etc/python/grass/lib/gis.py and
/usr/local/grass78/etc/python/grass/lib/raster.py my scripts seem to work
(gui dispalyed)

my LOCAL is LANG=fr_FR.UTF-8

New description:

After installing grass 7.8.3 on debian buster my python2 scripts does not
work anymore. Error message :

{{{

Traceback (most recent call last):
   File "/usr/local/grass78/gui/wxpython/gui_core/forms.py",
line 2866, in ParseCommand

blackList=_blackList)
   File "/usr/local/grass78/etc/python/grass/script/task.py",
line 522, in parse_interface

tree = etree.fromstring(get_interface_description(name))
   File "/usr/local/grass78/etc/python/grass/script/task.py",
line 498, in get_interface_description

"\n\nDetails: <{det}>").format(cmd=cmd, det=decode(cmderr)))
grass.exceptions
.
ScriptError
:
Unable to fetch interface description for command
'<r.wtg.visibility>'.
Details: <Traceback (most recent call last):
   File
"/home/frank/.grass7/addons/scripts/r.wtg.visibility", line
299, in <module>
     from grass.pygrass.utils import set_path
   File
"/usr/local/grass78/etc/python/grass/pygrass/utils.py", line
7, in <module>
     import grass.lib.gis as libgis
   File "/usr/local/grass78/etc/python/grass/lib/gis.py",
line 4
SyntaxError: Non-ASCII character '\xc3' in file
/usr/local/grass78/etc/python/grass/lib/gis.py on line 5,
but no encoding declared; see
http://python.org/dev/peps/pep-0263/ for details
>
During handling of the above exception, another exception
occurred:
Traceback (most recent call last):
   File "/usr/local/grass78/gui/wxpython/core/gconsole.py",
line 493, in RunCmd

task = GUI(show=None).ParseCommand(command)
   File "/usr/local/grass78/gui/wxpython/gui_core/forms.py",
line 2868, in ParseCommand

raise gcmd.GException(e.value)
core.gcmd
.
GException
:
Unable to fetch interface description for command
'<r.wtg.visibility>'.
Details: <Traceback (most recent call last):
   File
"/home/frank/.grass7/addons/scripts/r.wtg.visibility", line
299, in <module>
     from grass.pygrass.utils import set_path
   File
"/usr/local/grass78/etc/python/grass/pygrass/utils.py", line
7, in <module>
     import grass.lib.gis as libgis
   File "/usr/local/grass78/etc/python/grass/lib/gis.py",
line 4
SyntaxError: Non-ASCII character '\xc3' in file
/usr/local/grass78/etc/python/grass/lib/gis.py on line 5,
but no encoding declared; see
http://python.org/dev/peps/pep-0263/ for details
>
During handling of the above exception, another exception
occurred:
Traceback (most recent call last):
   File "/usr/local/grass78/gui/wxpython/gui_core/prompt.py",
line 413, in OnKeyPressed

self._runCmd(self.GetCurLine()[0].strip())
   File "/usr/local/grass78/gui/wxpython/gui_core/prompt.py",
line 120, in _runCmd

self.promptRunCmd.emit(cmd=cmd)
   File
"/usr/local/grass78/etc/python/grass/pydispatch/signal.py",
line 229, in emit

dispatcher.send(signal=self, *args, **kwargs)
   File "/usr/local/grass78/etc/python/grass/pydispatch/dispa
tcher.py", line 349, in send

**named
   File "/usr/local/grass78/etc/python/grass/pydispatch/robus
tapply.py", line 60, in robustApply

return receiver(*arguments, **named)
   File
"/usr/local/grass78/gui/wxpython/gui_core/goutput.py", line
120, in <lambda>

self._gconsole.RunCmd(command=cmd))
   File "/usr/local/grass78/gui/wxpython/core/gconsole.py",
line 496, in RunCmd

message=unicode(e),
NameError
:
name 'unicode' is not defined
}}}

----------------------
If I add

{{{
# -*- coding:UTF-8 -*-
}}}

on first line in /usr/local/grass78/etc/python/grass/lib/gis.py and
/usr/local/grass78/etc/python/grass/lib/raster.py my scripts seem to work
(gui dispalyed)

my LOCAL is LANG=fr_FR.UTF-8

--

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

#4017: run addon failed > name 'unicode' is not defined
---------------------+---------------------------------
  Reporter: 1266 | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.8.3
Component: wxGUI | Version: git-releasebranch78
Resolution: | Keywords: python3
       CPU: x86-64 | Platform: Linux
---------------------+---------------------------------

Comment (by marisn):

This seems to be a self compiled GRASS install. Please provide a full path
to GRASS source directory. My guess — the path to GRASS source contains a
non-ascii char (username?) and it is written into the header of gis.py as
a comment.

Injecting # -*- coding:UTF-8 -*- by ctypesgen could be a good solution for
the issue. Second option would be to strip header comment block
completely.

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

#4017: run addon failed > name 'unicode' is not defined
---------------------+---------------------------------
  Reporter: 1266 | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.8.3
Component: wxGUI | Version: git-releasebranch78
Resolution: | Keywords: python3
       CPU: x86-64 | Platform: Linux
---------------------+---------------------------------

Comment (by 1266):

Hello,
The french download default folder is "Téléchargements". It's from this
folder I have installed grass. Si This string appear in the file numerous
time. grep Téléchargements /usr/local/grass78/etc/python/grass/lib/gis.py
| wc -l return 696. I will keep -*- coding UTF-8 -*-
But for future, it could be useful to take this in account for all
language with special characters ?
Regards
Frank

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

#4017: run addon failed > name 'unicode' is not defined
---------------------+---------------------------------
  Reporter: 1266 | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.8.3
Component: wxGUI | Version: git-releasebranch78
Resolution: | Keywords: python3
       CPU: x86-64 | Platform: Linux
---------------------+---------------------------------

Comment (by neteler):

It's probably fine to inject `-*- coding UTF-8 -*-` into the ctypesgen
generated files but I am surprised that this comes up only now (and we
have definitely French language users :-).

Maybe the underlying reason is a different one?

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