Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#277 closed defect (fixed)

Fix sys.executable detection

Reported by: dmik Owned by:
Priority: major Milestone:
Component: python Version:
Severity: medium Keywords:
Cc:

Description

This works right:

D:>python -c 'import sys; print sys.executable'
C:/USR/BIN/python.exe

This works wrong:

D:>python2.7 -c 'import sys; print sys.executable'
D:/Coding/Tests/python/

Change History (3)

comment:1 by dmik, 7 years ago

The problem popped up during Firefox 52 build configuration, see https://github.com/bitwiseworks/mozilla-os2/issues/240#issuecomment-337417294 for details.

comment:2 by dmik, 7 years ago

Resolution: fixed
Status: newclosed

Fixed in r1251. Note that this break, as many other breaks, was a result of switching from OS/2 specific code to generic Posix code when rebuilding Python within the RPM environment. As a result, the ".exe" extension was not counted in when searching for an executable. Luckily, we have _path2 in kILBC which can do all the dirty work for us in this case (as opposed to other Posix platforms where they have to always do it manually).

comment:3 by dmik, 7 years ago

JFYI, the reason why it would return a curdir instead is because the code is written so that when the exe used to start the given python application is not found on PATH (e.g. was removed or was made non-executable), the resulting exe will become "" which, when resolved into an absolute path (i.e. joined with CWD) becomes what you see above.

Now, with the fix from r1251, the output of the first invocation is:

C:/USR/BIN/python

and the second one gives is:

C:/USR/BIN/python2.7.exe

Note that no .exe was added in the first case, because kLIBC (and its _path2) can properly start both real executables w/o .exe and symlinks (given that they point to valid executable) hence it reports whichever matches python first which is the symlink pointing to python.exe. This is normal for the RPM environment.

Note: See TracTickets for help on using tickets.