[issue15020] default value for progname in pythonrun.c should be python3 for Python 3
Joshua Cogliati
report at bugs.python.org
Thu Jul 5 20:53:41 CEST 2012
Joshua Cogliati <jrincayc at gmail.com> added the comment:
> Joshua, if you are embedding Python, why don't you simply call Py_SetPath to set the search path appropriately? Or is it not enough? (I've lost memory of the mazy details of how we calculate paths :-S).
Setting Py_SetPath manually would basically require me to replicate the work done in Modules/getpath.c to figure out where the python libraries are. I already set PYTHONPATH to get it to find my own modules. (Note that there is a big difference between setting PYTHONPATH the environmental variable and calling Py_SetPath, Py_SetPath assumes that you are setting the python library module paths as well.)
The basic problem is that in function calculate_path (inside of Modules/getpath.c ) it has the following code:
char *_path = getenv("PATH");
...
wchar_t *prog = Py_GetProgramName();
...
while (1) {
...
joinpath(progpath, prog);
if (isxfile(progpath))
break;
...
which goes through the path and tries to find an executable with the same name as returned by Py_GetProgramName()
So if I do a """Py_SetProgramName(L"python3");""" that method works because prog="python3" but if I don't then the method fails because prog="python".
Basically, to fix this bug, somehow, "wchar_t *prog =" in calculate_path needs to get the actual python executable for this version of python.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15020>
_______________________________________
More information about the Python-bugs-list
mailing list