STINNER Victor <victor.stin...@haypocalc.com> added the comment:

r78835 (trunk) fixes getpath and includes also a fix for sysconfig which should 
fix test_executable_with_cwd() of test_subprocess.

My fix on sysconfig is different than flox's patch: since I fixed getpath, 
sys.executable cannot be a directory name. At revision r78835, sys.executable 
can have 3 values:
 (a) absolute path to Python executable name (most common case)
 (b) empty string if argv[0] has been set to a non existent program name
 (c) absolute path to a different program if argv[0] has been set to a 
different program, with or without path (eg. "true" and "/bin/path")

(c) is the worst case: Python refuses to start. r78835 fixes the site module 
error for case (b).

There are different methods to get the real program name, but no one is 
portable. As flox wrote, we can "do a best effort to provide a valid 
sys.executable". Extract of stackoverflow link:

 * Mac OS X: _NSGetExecutablePath() (man 3 dyld)
 * Linux: readlink /proc/self/exe
 * Solaris: getexecname()
 * FreeBSD: sysctl CTL_KERN KERN_PROC KERN_PROC_PATHNAME -1
 * BSD with procfs: readlink /proc/curproc/file
 * Windows: GetModuleFileName() with hModule = NULL

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue7774>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to