Bug in python startup on linux? [Was: Wrong Executable? or something]
Bernhard Herzog
herzog at online.de
Tue Dec 21 15:47:27 EST 1999
Siggy Brentrup <bsb at winnegan.de> writes:
> Clarence Gardner <clarence at beach.silcom.com> writes:
>
> > This is a problem I've seen on many linux systems. They're all RedHat or
> > Mandrake (extended RedHat).
>
> Same holds for Debian slink aka 2.1
>
> I did a little more testing and found out that results depend on your
> PATH setting.
>
> Calling scripts with an empty PATH gives the expected results
[snip proof]
> I suspect a bug in the python startup routine, since sys.prefix
> and sys.exec_prefix are determined at configuration time.
Python tries to initialize sys.path based on the location of the python
executable. If argv[0] contains no '/' python searches $PATH for the
executable and starts from there.
On Linux it seems that a program called by the #! mechanism only gets
the basename of the file in argv[0], i.e. there's no '/' and therefore
python searches through the directories in $PATH, so it might get the
wrong one.
I'm not sure whether this is to be considered a bug in Linux or Python,
but Python could perhaps work around this on a Linux system by using
/proc/self/exe (which is a symbolic link to the executable of the
process) as reference when it searches $PATH for the file.
--
Bernhard Herzog | Sketch, a drawing program for Unix
herzog at online.de | http://sketch.sourceforge.net/
More information about the Python-list
mailing list