Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The file /usr/lib/python2.7/os.py has on my machine the following content around the critical line marked with <---- below:

def _execvpe(file, args, env=None):
    if env is not None:
        func = execve
        argrest = (args, env)
    else:
        func = execv
        argrest = (args,)
        env = environ

    head, tail = path.split(file)
    if head:
        func(file, *argrest)
        return
    if 'PATH' in env:
        envpath = env['PATH']
    else:
        envpath = defpath
    PATH = envpath.split(pathsep)
    saved_exc = None
    saved_tb = None
    for dir in PATH:
        fullname = path.join(dir, file)
        try:
            func(fullname, *argrest)    # <---- CRITICAL LINE Number 382 in the error mess
        except error, e:
            tb = sys.exc_info()[2]
            if (e.errno != errno.ENOENT and e.errno != errno.ENOTDIR
                and saved_exc is None):
                saved_exc = e
                saved_tb = tb
    if saved_exc:
        raise error, saved_exc, saved_tb
    raise error, e, tb

(It is already pretty bad that the code uses variables like dir and file for the own purposes, but let it be so, we have an other problem.)

As seen, for each dir in the PATH we try to do something. We call func, which is either execve or execv, against the dir joined with file, and there are also some ** arguments... The error shows that the PATH and\or the file runs into an error.

My strategy in such cases is to edit the py-file inserting a print in the loop with the error. (This is one beautiful profit of having open sources.) Which is now exactly the "bad path" and/or "bad file"?