[GRASS-dev] [GRASS-SVN] r60679 - grass/trunk/lib/python/script

Glynn Clements glynn at gclements.plus.com
Wed Jun 4 10:56:58 PDT 2014


Pietro wrote:

> > Reminder for all Windows users, please note that winGRASS 7.1 no.>981
> > will be broken (calling python script from python script issue - eg.
> > wxGUI Extension manager) again.
> >
> > 2014-06-03 7:24 GMT+02:00  <svn_grass at osgeo.org>:
> >> Author: glynn
> >> Date: 2014-06-02 22:24:32 -0700 (Mon, 02 Jun 2014)
> >> New Revision: 60679
> >>
> >> Modified:
> >>    grass/trunk/lib/python/script/core.py
> >> Log:
> >> Remove Popen() "magic" on Windows; it creates more problems than it solves
> 
> Please, could you explain which problems creates?

The shell doesn't simply pass its arguments to the program being
executed; it may interpret them (e.g. performing redirection in the
presence of |, < or > characters). For a specific example of why this
is a problem, see ticket #2314.

	http://trac.osgeo.org/grass/ticket/2314

The quoting performed by the subprocess module (specifically, the
list2cmdline() function) doesn't take this into account (i.e. it
doesn't perform any additional quoting when shell=True).

So either:

1. GRASS 7 will need .bat wrappers for Python scripts on Windows. That
has the same issues as using shell=True, but at least it only applies
in the case where we're executing a script.

2. If we know that the "program" is a script, the interpreter can be
specified explicitly (i.e. "python path/to/script.py"). This keeps the
shell out of the picture.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list