This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: os.spawnv() fails with underscores
Type: Stage:
Components: Library (Lib) Versions: Python 2.2
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: loewis Nosy List: brett.cannon, loewis, nokta_kanto, tim.peters
Priority: normal Keywords:

Created on 2002-06-30 22:15 by nokta_kanto, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
ret111.exe nokta_kanto, 2002-08-06 22:54 The test binary
Messages (9)
msg11403 - (view) Author: Chris Rodrigues (nokta_kanto) Date: 2002-06-30 22:15
 I'm running Python 2.2 in Windows 98. 
 
When trying to os.spawnv() a program in a path that contains an 
underscore, the program does not run but no error message is 
printed.  This error happens in the dos version of Python 2.2, but 
not in IDLE. 
 
I detected the error by creating a DOS program that returns the 
recognizable value 111. If I call that file "c:\ret111.exe" and run it with 
the following command: 
 
os.spawnv( os.P_WAIT, progname, [progname] ) 
 
where progname is the full path and name of the program, then the 
function returns the value 111.  If I put that file in 
"c:\pulse_prog\ret111.exe", and run the same command with the new 
value of progname, then the return value is 111 in IDLE but 0 in 
dos-prompt python. 
msg11404 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-07-05 05:52
Logged In: YES 
user_id=21627

Can you please attach the test program to this report?
msg11405 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2002-07-05 16:46
Logged In: YES 
user_id=31435

I can't reproduce this using 2.2.1 under Win98SE.  Here's 
a screen dump showing exactly what I did.  Please show us 
exactly what you did.

C:\pulse_prog>type ret111.c
int main() { return 111; }

C:\pulse_prog>cd \python22

C:\Python22>python
Python 2.2.1 (#34, Apr  9 2002, 19:34:33) [MSC 32 bit 
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more 
information.
>>> import os
>>> prog = r"c:\pulse_prog\ret111"
>>> os.spawnv(os.P_WAIT, prog, [prog])
111
>>>
msg11406 - (view) Author: Chris Rodrigues (nokta_kanto) Date: 2002-07-19 21:22
Logged In: YES 
user_id=571002

Here's a screen dump of the error in progress.

I don't know if it makes a difference, but ret111.exe was compiled with 
djgpp.

C:\pulse_prog>type ret111.c
int main() {return 111;}

C:\pulse_prog>python
Python 2.2.1c2 (#33, Mar 26 2002, 13:04:18) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.spawnv( os.P_WAIT, r'c:\ret111.exe', [r'c:\ret111.exe'])
111
>>> os.spawnv( os.P_WAIT, r'c:\pulse_prog\ret111.exe', 
[r'c:\pulse_prog\ret111.exe'])
0
>>>
msg11407 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-07-30 14:27
Logged In: YES 
user_id=21627

Can you please attach the binary to this report?
msg11408 - (view) Author: Chris Rodrigues (nokta_kanto) Date: 2002-08-06 22:54
Logged In: YES 
user_id=571002

I've attached the binary file.
msg11409 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2003-05-17 02:36
Logged In: YES 
user_id=357491

Can anyone with Win98 test this to see if this is still a bug?
msg11410 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2003-05-17 03:10
Logged In: YES 
user_id=31435

Assigned to Martin since he asked for the binary, and I 
don't know what he wanted to do with it.

I tried it (still on Win98SE), and I do get a return value of 0 
from spawnv -- sometimes.  It doesn't have anything to do 
with whether there's an underscore in the path name for 
me, it has solely to do with whether the directory name has 
more than 8 characters.  So, using:

c:\pulse_prog\ret111.exe -- returns 0
c:\pulseprog\ret111.exe -- returns 0
c:\pulsepro\ret111.exe -- returns 111

More, this doesn't appear to have anything to do with 
Python.  I get the same results with this straight C 
program, compiled under MSVC 6:

#include <stdio.h>
#include <process.h>

void main() {
    int rc;
    char *prog = "c:\\pulseprog\\ret111.exe";
    char *whatever[] = {prog, 0};

    rc = _spawnv(_P_WAIT, prog, whatever);
    printf("return code %d\n", rc);
}

I have to conclude this has something to do with the 
compiler Chris is using.  It doesn't appear to be a Python 
bug in any case.
msg11411 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2003-05-17 08:15
Logged In: YES 
user_id=21627

I wanted to reproduce this, since I couldn't reproduce it
with a program I had written on my own. As Tim has now found
out, this is a bug in the program being invoked, not in
Python, so closing as not-a-bug.
History
Date User Action Args
2022-04-10 16:05:28adminsetgithub: 36829
2002-06-30 22:15:13nokta_kantocreate