RE: Running Python (Windows) with _spawnvp requires unexpectedquotesaround arguments

Discussion in 'Python' started by Tim Peters, Oct 26, 2003.

  1. Tim Peters

    Tim Peters Guest

    [Elmar Krieger]
    > The _spawnvp function expects the command line arguments as a NULL
    > terminated list of char * pointers,


    That's true.

    > hence there is no need to enclose filenames with quotes if they
    > contain spaces.


    But that's not true, on Windows. The Microsoft implementation of the spawn
    functions uses the Win32 CreateProcess(), which doesn't take an array of
    arguments -- it takes a pointer to a single command line string. The MS
    implementation pastes all the arguments into that single string before
    calling CreateProcess(), replacing the terminating NUL character in each
    argument with a single blank (except the last argument, whose terminating
    NUL is left alone, and so serves as the terminating NUL character of the
    command line string). CreateProcess() in turn then can't tell the
    difference between a blank inserted by a spawn function and a blank
    originally present in one of your arguments.

    > However, if I run pythonw.exe with _spawnvp, and the Python script to
    > execute (that's the second command line parameter) has spaces in the
    > pathname, it only works if the pathname is enclosed with quotes.
    > Is that OK?


    That is how it works.
     
    Tim Peters, Oct 26, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    396
    Hendrik Maryns
    Mar 6, 2006
  2. Elmar Krieger
    Replies:
    0
    Views:
    334
    Elmar Krieger
    Oct 26, 2003
  3. Edward Diener
    Replies:
    14
    Views:
    5,117
    Josiah Carlson
    Apr 6, 2004
  4. Neo
    Replies:
    10
    Views:
    700
    sushant
    Jan 20, 2005
  5. Sherman Willden
    Replies:
    1
    Views:
    156
    Sisyphus
    Jul 25, 2003
Loading...

Share This Page