[Python-Dev] subprocess insufficiently platform-independent?

Jean-Paul Calderone exarkun at divmod.com
Mon Aug 25 19:44:09 CEST 2008

On Mon, 25 Aug 2008 10:13:32 -0700, Guido van Rossum <guido at python.org> wrote:
>Several people at Google seem to have independently discovered that
>despite all of the platform-independent goodness in subprocess.py, you
>still need to be platform aware. One of my colleagues summarized it
>like this:
>Given a straightforward command list like:
>    cmd = ['svn', 'ls', 'http://rietveld.googlecode.com/svn/trunk']

Launching child processes on Windows is actually pretty hard to do.
The idea of an array of arguments is more like a group hallucination
than a reality there.  If you assume certain things about how the
launched process will interpret its command line (something each
program gets to decide for itself on Windows), and many programs do
actually use the same rules, then you can get something together that
mostly works and is mostly general.

Twisted's process support does this and presents a cross-platform API
(at least as far as arguments are concerned).  Perhaps the subprocess
module should borrow that implementation?


This doesn't handle all possible inputs correctly (you can read about its
flaws in some detail at <http://twistedmatrix.com/trac/ticket/1123>) but
it does handle *most* inputs.  It also isn't appropriate for all programs,
but for the programs which don't follow these quoting rules, it's probably
a mistake to have a list-based API anyway: they should be invoked using one
string giving the entire command line.


More information about the Python-Dev mailing list