PyAPI_FUNC(wchar_t *) Py_GetPythonHome(void);
#ifndef Py_LIMITED_API
+PyAPI_FUNC(void) _Py_SetProgramFullPath(const wchar_t *);
+
/* Only used by applications that embed the interpreter and need to
* override the standard encoding determination mechanism
*/
}
+static _PyInitError
+config_init_executable(_PyCoreConfig *config)
+{
+ assert(config->executable == NULL);
+
+ /* If Py_SetProgramFullPath() was called, use its value */
+ const wchar_t *program_full_path = _Py_path_config.program_full_path;
+ if (program_full_path != NULL) {
+ config->executable = _PyMem_RawWcsdup(program_full_path);
+ if (config->executable == NULL) {
+ return _Py_INIT_NO_MEMORY();
+ }
+ return _Py_INIT_OK();
+ }
+
+ return _Py_INIT_OK();
+}
+
+
static void
pymain_header(_PyMain *pymain)
{
}
}
+ if (config->executable == NULL) {
+ err = config_init_executable(config);
+ if (_Py_INIT_FAILED(err)) {
+ return err;
+ }
+ }
+
if (config->utf8_mode < 0 || config->coerce_c_locale < 0) {
config_init_locale(config);
}
}
+void
+_Py_SetProgramFullPath(const wchar_t *program_full_path)
+{
+ if (program_full_path == NULL || program_full_path[0] == L'\0') {
+ return;
+ }
+
+ PyMemAllocatorEx old_alloc;
+ _PyMem_SetDefaultAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
+
+ PyMem_RawFree(_Py_path_config.program_full_path);
+ _Py_path_config.program_full_path = _PyMem_RawWcsdup(program_full_path);
+
+ PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
+
+ if (_Py_path_config.program_full_path == NULL) {
+ Py_FatalError("Py_SetProgramFullPath() failed: out of memory");
+ }
+}
+
+
wchar_t *
Py_GetPath(void)
{