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? http://twistedmatrix.com/trac/browser/trunk/twisted/python/win32.py#L66 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. Jean-Paul
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4