If we set argv0 to ".":
if (_Py_wgetcwd(fullpath, Py_ARRAY_LENGTH(fullpath))) {
argv0 = fullpath;
n = wcslen(argv0);
}
else {
argv0 = L".";
n = 1;
}
then the caller does not have any way of knowing if the returned argv0 is due
to the fact that _Py_wgetcwd failed so it will blindly add "." to sys.path unless
we set the result using PyObject** and then returning some error code to signal
what happened (or something similar). On the other hand, I do not like this API,
because returning some error code != 0 from _PyPathConfig_ComputeArgv0 would be
weird because the call actually succeeded (it has returned "." as the value for argv0).
What do you think is the best way to signal pymain_run_python that the current directory
does not exist (because _Py_wgetcwd has failed)? |