[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 17:15:27 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 glynn):
Replying to [comment:13 annakrat]:
> The `command[0]` is Unicode. It seems Popen in Python 2.7 can't handle
non-ascii characters.
It's more accurate to say that it can't handle unicode. Or, more
precisely, unicode which cannot be implicitly converted to a string.
Implicit conversions use the default encoding (which is typically ASCII)
rather than the locale's encoding. The default encoding is a system or
user preference and cannot be changed by scripts.
> So I tried to encode the command string and I get different error:
>
{{{
raise err
xml.etree.ElementTree
.
ParseError
}}}
> It seems that get_interface_description returns empty xml
Did you confirm that?
Otherwise, my guess is that the XML is invalid due to encoding issues.
The program name is copied verbatim into the XML, in the <task name="...">
tag.
If GRASS was built with iconv support, the declared encoding of the XML
will be UTF-8; text nodes will be convert from the locale's encoding to
UTF-8 (and <,>,& will be converted to entities), but attribute values
aren't converted:
{{{
fprintf(stdout, "<task name=\"%s\">\n", st->pgm_name);
}}}
So, they need to be restricted to the intersection of the locale's
encoding and UTF-8 (which probably means ASCII).
I'm not sure that it's worth trying to support script names which contain
non-ASCII characters. However, scripts in directories whose names contain
non-ASCII characters need to be supported. The same applies to other
files; e.g. we can reasonably restrict map, mapset and location names to
ASCII, but we should support the situation where the database path
contains non-ASCII characters.
In any case, the GUI should be encoding the arguments which it passes to
Popen(); it shouldn't be passing unicode values.
--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2532#comment:14>
GRASS GIS <http://grass.osgeo.org>
More information about the grass-dev
mailing list