[GRASS-dev] [GRASS GIS] #2532: TypeError: environment can only contain string when launching script on Windows

GRASS GIS trac at osgeo.org
Sat Jan 17 07:13:12 PST 2015


#2532: TypeError: environment can only contain string when launching script on
Windows
-------------------------+--------------------------------------------------
 Reporter:  annakrat     |       Owner:  grass-dev@…              
     Type:  defect       |      Status:  new                      
 Priority:  normal       |   Milestone:  7.0.0                    
Component:  Default      |     Version:  svn-trunk                
 Keywords:  encoding     |    Platform:  MSWindows 8              
      Cpu:  Unspecified  |  
-------------------------+--------------------------------------------------

Comment(by annakrat):

 Replying to [comment:11 annakrat]:
 > Replying to [comment:10 glynn]:
 > > Replying to [comment:8 annakrat]:
 > >
 > It gives me False. I will try to see if there is something wrong in the
 gui part.

 I found that there is raised and ignored exception
 [http://trac.osgeo.org/grass/browser/grass/trunk/gui/wxpython/core/gconsole.py#L554
 here] and if I remove the try except block, I get:

 {{{
 Traceback (most recent call last):
   File "C:\Users\akratoc\Programs\GRASS GIS
 7.1.svn\gui\wxpython\lmgr\frame.py", line 907, in
 OnRunScript

 self._gconsole.RunCmd([filename])
   File "C:\Users\akratoc\Programs\GRASS GIS
 7.1.svn\gui\wxpython\core\gconsole.py", line 554, in RunCmd

 task = gtask.parse_interface(command[0])
   File "C:\Users\akratoc\Programs\GRASS GIS
 7.1.svn\etc\python\grass\script\task.py", line 509, in
 parse_interface

 tree = etree.fromstring(get_interface_description(name))
   File "C:\Users\akratoc\Programs\GRASS GIS
 7.1.svn\etc\python\grass\script\task.py", line 465, in
 get_interface_description

 stderr=PIPE)
   File "C:\Users\akratoc\Programs\GRASS GIS
 7.1.svn\etc\python\grass\script\core.py", line 62, in
 __init__

 subprocess.Popen.__init__(self, args, **kwargs)
   File "C:\Users\akratoc\Programs\GRASS GIS
 7.1.svn\Python27\lib\subprocess.py", line 711, in __init__

 errread, errwrite)
   File "C:\Users\akratoc\Programs\GRASS GIS
 7.1.svn\Python27\lib\subprocess.py", line 922, in
 _execute_child

 args = '{} /c "{}"'.format (comspec, args)
 UnicodeEncodeError
 'ascii' codec can't encode character u'\xe1' in position 38: ordinal not
 in range(128)
 }}}

 The `command[0]` is Unicode. It seems Popen in Python 2.7 can't handle
 non-ascii characters. So I tried to encode the command string and I get
 different error:


 {{{
 Traceback (most recent call last):
   File "C:\Users\akratoc\Programs\GRASS GIS
 7.1.svn\gui\wxpython\lmgr\frame.py", line 907, in
 OnRunScript

 self._gconsole.RunCmd([filename])
   File "C:\Users\akratoc\Programs\GRASS GIS
 7.1.svn\gui\wxpython\core\gconsole.py", line 555, in RunCmd

 task = gtask.parse_interface(EncodeString(command[0]))
   File "C:\Users\akratoc\Programs\GRASS GIS
 7.1.svn\etc\python\grass\script\task.py", line 509, in
 parse_interface

 tree = etree.fromstring(get_interface_description(name))
   File "C:\Users\akratoc\Programs\GRASS GIS
 7.1.svn\Python27\lib\xml\etree\ElementTree.py", line 1300,
 in XML

 parser.feed(text)
   File "C:\Users\akratoc\Programs\GRASS GIS
 7.1.svn\Python27\lib\xml\etree\ElementTree.py", line 1642,
 in feed

 self._raiseerror(v)
   File "C:\Users\akratoc\Programs\GRASS GIS
 7.1.svn\Python27\lib\xml\etree\ElementTree.py", line 1506,
 in _raiseerror

 raise err
 xml.etree.ElementTree
 .
 ParseError
 :
 syntax error: line 1, column 0
 }}}


 It seems that `get_interface_description` returns empty xml. I didn't have
 time to look into it further.

-- 
Ticket URL: <http://trac.osgeo.org/grass/ticket/2532#comment:13>
GRASS GIS <http://grass.osgeo.org>



More information about the grass-dev mailing list