bpo-32030: Add _PyMainInterpreterConfig.executable by vstinner · Pull Request #4876 · python/cpython
#undef SET_SYS_FROM_STRING #undef SET_SYS_FROM_STRING_BORROW
/* Updating the sys namespace, returning integer error codes */ #define SET_SYS_FROM_STRING_INT_RESULT(key, value) \
int _PySys_EndInit(PyObject *sysdict) _PySys_EndInit(PyObject *sysdict, _PyMainInterpreterConfig *config) { int res;
/* _PyMainInterpreterConfig_Read() must set all these variables */ assert(config->module_search_path != NULL); assert(config->executable != NULL); assert(config->prefix != NULL); assert(config->base_prefix != NULL); assert(config->exec_prefix != NULL); assert(config->base_exec_prefix != NULL);
SET_SYS_FROM_STRING_BORROW("path", config->module_search_path); SET_SYS_FROM_STRING_BORROW("executable", config->executable); SET_SYS_FROM_STRING_BORROW("prefix", config->prefix); SET_SYS_FROM_STRING_BORROW("base_prefix", config->base_prefix); SET_SYS_FROM_STRING_BORROW("exec_prefix", config->exec_prefix); SET_SYS_FROM_STRING_BORROW("base_exec_prefix", config->base_exec_prefix);
if (config->argv != NULL) { SET_SYS_FROM_STRING_BORROW("argv", config->argv); } if (config->warnoptions != NULL) { SET_SYS_FROM_STRING_BORROW("warnoptions", config->warnoptions); } if (config->xoptions != NULL) { SET_SYS_FROM_STRING_BORROW("_xoptions", config->xoptions); }
/* Set flags to their final values */ SET_SYS_FROM_STRING_INT_RESULT("flags", make_flags()); /* prevent user from creating new instances */
SET_SYS_FROM_STRING_INT_RESULT("dont_write_bytecode", PyBool_FromLong(Py_DontWriteBytecodeFlag)); SET_SYS_FROM_STRING_INT_RESULT("executable", PyUnicode_FromWideChar( Py_GetProgramFullPath(), -1)); SET_SYS_FROM_STRING_INT_RESULT("prefix", PyUnicode_FromWideChar(Py_GetPrefix(), -1)); SET_SYS_FROM_STRING_INT_RESULT("exec_prefix", PyUnicode_FromWideChar(Py_GetExecPrefix(), -1)); SET_SYS_FROM_STRING_INT_RESULT("base_prefix", PyUnicode_FromWideChar(Py_GetPrefix(), -1)); SET_SYS_FROM_STRING_INT_RESULT("base_exec_prefix", PyUnicode_FromWideChar(Py_GetExecPrefix(), -1));
if (get_warnoptions() == NULL) return -1;
err_occurred: return -1; }
#undef SET_SYS_FROM_STRING_BORROW #undef SET_SYS_FROM_STRING_INT_RESULT
static PyObject *