[Python-Dev] Weird error handling in os._execvpe
Guido van Rossum
guido@python.org
Thu, 01 Aug 2002 19:36:50 -0400
> > > 1. Make os.execvp[e] just call the C library's execvp[e]; it has to
> > > get this stuff right anyway. We are already counting on it for
> > > execv - I would be surprised to find a system that had execv and
> > > not execvp, as long as PATH was a meaningful concept (it isn't, for
> > > instance, on classic MacOS).
> >
> > Probably agreed for execvpe(). All the non-env versions must call the
> > env version because not all platforms have putenv, and there changes
> > to os.environ don't get reflected in the process's environment.
>
> execvp could be just
>
> def execvp(file, args):
> return execvpe(file, args, environ)
>
> yes?
It already is, sort of:
def execvp(file, args):
"""execp(file, args)
Execute the executable file (which is searched for along $PATH)
with argument list args, replacing the current process.
args may be a list or tuple of strings. """
_execvpe(file, args)
> > > 2. Enumerate all the platform-specific errno values for this failure
> > > mode, and check them all. On Unix, ENOENT and arguably ENOTDIR. I
> > > don't know about others.
> > >
> > > 3. If we must do the temporary file thing, create a temporary
> > > _directory_; we control the contents of that directory, so we can
> > > be sure that the file name we choose does not exist. Cleanup is
> > > messier than the other two possibilities.
> >
> > I like to agree with this, but I don't recall exactly why we ended up
> > in this situation in the first place. It's possible that it's an
> > unnecessary sacrifice of a dead chicken, but it's also possible that
> > there are platforms where this addressed a real need. I'd like to
> > think that it was because I didn't want to add more cruft to
> > posixmodule.c (I've long given up on that :-).
> >
> > Can you post a patch to SF? Then we can ask for volunteers to test it
> > on various platforms.
>
> I will write such a patch, however, I keep getting lost in the Python
> source tree. In addition to Modules/posixmodule.c, I would need to
> update the nt, dos, os2, mac, ce, and riscos modules also, yes? Where
> are their sources kept? I don't see an ntmodule.c, etc anywhere.
The nt module is built from the posixmodule.c source file. AFAIK the
others don't support the exec* family at all, so don't worry about
them; if something is needed the respective maintainers will have to
provide it.
--Guido van Rossum (home page: http://www.python.org/~guido/)