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

Kurt B. Kaiser kbk at shore.net
Fri Aug 8 20:37:22 EDT 2003


On Wed, 6 Aug 2003 23:17:44 -0400, Tim Peters <tim.one at comcast.net> wrote:
> I have no evidence of an MS bug here.  My sisters like putting spaces in
> file names, which is why MS started allowing them.  The backward
> compatibility problem then was severe, especially given system shells 
> with
> weak and inconsistent quoting gimmicks.  Python doesn't try to hide this 
> on
> Windows, and using spawn() or system() successfully from Python on 
> Windows
> requires that you deal with whitespace in the executable's path yourself.

(I put a copy of python.exe at c:\ to allow the first example below to 
work.)

Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on 
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>>
>>> executable = 'c:\\python'
>>> os.spawnv(os.P_NOWAIT, executable, (executable, '-V'))
1948
>>> Python 2.3
>>>
>>> executable = 'c:\"Program Files"\Python23\python'
>>> executable
'c:"Program Files"\\Python23\\python'
>>> os.spawnv(os.P_NOWAIT, executable, (executable, '-V'))
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
OSError: [Errno 22] Invalid argument

=====================================================
and that version of executable isn't an absolute path

=====================================================

>>> executable = 'c:\\\"Program Files"\Python23\python'
>>> executable
'c:\\"Program Files"\\Python23\\python'
>>> os.spawnv(os.P_NOWAIT, executable, (executable, '-V'))
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
OSError: [Errno 22] Invalid argument
>>>
>>> executable = '"c:\Program Files\Python23\python"'
>>> executable
'"c:\\Program Files\\Python23\\python"'
>>> os.spawnv(os.P_NOWAIT, executable, (executable, '-V'))
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
OSError: [Errno 22] Invalid argument
>>>
>>> executable = 'c:\PROGRA~1\Python23\python'
>>> executable
'c:\\PROGRA~1\\Python23\\python'
>>> os.spawnv(os.P_NOWAIT, executable, (executable, '-V'))
1944
>>> Python 2.3
========================

Can someone offer advice on what I need to do to create a valid os.spawnv 
call involving
"Program Files" that will work in the above examples?  The posts I've been 
able to find
essentially say, "just quote it," but I can't find a combination that works 
so I can fix
the IDLE startup bug.

-- 
KBK




More information about the Python-Dev mailing list