On Tue, Feb 25, 2014 at 4:54 PM, Dave Angel <da...@davea.name> wrote: > CreateProcess has its own design bobbles as well. For example, if > you forget to put quotes around the program name, it will > happily try to add ".exe" to *multiple* places in the hopes that > one of them will work. > > Adding a file c:\program.exe to a system will blow up lots of > programs that were working by mistake for years.
Yes, using a string requires quoting the path for the executable if you aren't using lpApplicationName (i.e. Popen's "executable"). I noticed for shell=True they aren't using list2cmdline for COMPSPEC; they just trust it. So I wrote the following test to exemplify the problem you're talking about: >>> import os, subprocess >>> open('temp.c', 'w').write(r''' ... #include <stdio.h> ... int main(int argc, char *argv[]) { ... printf("\n\n*** spam! ***\n\n"); ... return 0; ... }''') 107 >>> os.system('cl temp.c /FeC:\\Program.exe 1>nul 2>&1') 0 >>> os.environ['COMSPEC'] = r'C:\Program Files\doesnt\matter' >>> p = subprocess.Popen('dir', shell=True) >>> *** spam! *** _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor