[Python-Dev] test_popen broken on Win2K

Kevin Altis altis@semi-retired.com
Fri, 7 Mar 2003 14:31:21 -0800

> From: Thomas Heller
> Tim Peters <tim.one@comcast.net> writes:
> > Someone changed test_popen to "quote" the path to python:
> >
> >     cmd = '"%s" -c "import sys;print sys.argv" %s' % (sys.executable,
> > cmdline)
> >            ^  ^
> >
> > The double-quote characters above the carets are new.
> >
> > This causes test_popen to fail on Win2K, but not on Win98.  The relevant
> > difference appears to be the default shell (cmd.exe on the former,
> > command.com on the latter).
> In distutils we had a similar problem. I don't remember the details
> at the moment exactly, but I think enclosing sys.executable in double
> quotes *only* when it contains spaces should do the trick.

My example isn't for popen, but this sounds familiar. There are a few places
where I had to do things like this for some Win98 folks that installed
'Python22' into 'C:\Program Files\' instead of at 'C:\'

        if ' ' in sys.executable:
            python = '"' + sys.executable + '"'
            python = sys.executable
        os.spawnv(os.P_NOWAIT, python, [python, filename])

there have also been some quote issues with the arguments like filename and
I'm still not sure all the cases on various versions of Windows, Mac OS X,
and Linux work correctly all the time.

David Ascher is on vacation, otherwise he could tell us all about the
process.py module and how it relates to these issues :)