[Python-Dev] Re: FWD: Re: Problem w/ IDLE on Win2000

Kurt B. Kaiser kbk at shore.net
Sat Aug 9 16:08:32 EDT 2003


On Fri, 8 Aug 2003 23:44:15 -0400, Tim Peters <tim.one at comcast.net> wrote:

> [Kurt B. Kaiser, struggles to get an embedded-space spawn to work]
>
> I think the trick is that you shouldn't quote the executable path at all.

This is the key point.  Thanks.  I was trying to quote both the executable
and the arguments.  Now to try IDLE again....

> Under the covers, MS takes the executable name as-is, passing it as the
> lpApplicationName argument to the Win32 CreateProcess(), but squashes all
> your *arguments* into a single string, which gets passed on as the
> lpCommandLine argument to CreateProcess().
>
> In the arguments, you should avoid the cleverness of trying to quote only
> the part(s) with a space(s).  Stick a double quote on each end of each
> argument, and that's it(*).

[...]

> <arghghghgh>!

Does it make sense to update the spawn* docs to include a comment that
on Windows a spawn* /path/ with embedded spaces should not be quoted, but
an arg with embedded spaces should be decorated with double quotes on
each end?

============================================================
path with embedded space, XP:
============================================================

>>> executable = sys.executable
>>> executable
'C:\\Program Files\\Python23\\python.exe'
>>> decorated = '"%s"' % executable
>>> decorated
'"C:\\Program Files\\Python23\\python.exe"'
>>> os.spawnv(os.P_NOWAIT, executable, (decorated, '-V'))
1900
>>> Python 2.3

>>> os.spawnv(os.P_NOWAIT, executable, (executable, '-V'))
1896
>>> C:\Program: can't open file 'Files\Python23\python.exe'

>>> os.spawnv(os.P_NOWAIT, decorated, (decorated, '-V'))
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
OSError: [Errno 22] Invalid argument
>>>
===========================================================
** On W98 the second version works! **

And, BTW, IDLE1.0 runs on W98 even when Python23 is
installed in Program Files.



Now a path w/o embedded space, XP:
===========================================================
>>> executable = r'C:\python.exe'
>>> executable
'C:\\python.exe'
>>> decorated = '"%s"' % executable
>>> decorated
'"C:\\python.exe"'
>>> os.spawnv(os.P_NOWAIT, executable, (decorated, '-V'))
1892
>>> Python 2.3

>>> os.spawnv(os.P_NOWAIT, executable, (executable, '-V'))
1888
>>> Python 2.3

>>> os.spawnv(os.P_NOWAIT, decorated, (decorated, '-V'))
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
OSError: [Errno 22] Invalid argument
>>>
===========================================================
Same results on W98.





More information about the Python-Dev mailing list