PyAPI_FUNC(_PyInitError) _PyCoreConfig_InitPathConfig(_PyCoreConfig *config);
PyAPI_FUNC(_PyInitError) _PyCoreConfig_SetPathConfig(
const _PyCoreConfig *config);
-PyAPI_FUNC(_PyInitError) _PyCoreConfig_Read(_PyCoreConfig *config,
- const _PyArgv *args);
+PyAPI_FUNC(_PyInitError) _PyCoreConfig_Read(_PyCoreConfig *config);
PyAPI_FUNC(void) _PyCoreConfig_Write(const _PyCoreConfig *config,
_PyRuntimeState *runtime);
+PyAPI_FUNC(_PyInitError) _PyCoreConfig_SetPyArgv(
+ _PyCoreConfig *config,
+ const _PyArgv *args);
+PyAPI_FUNC(_PyInitError) _PyCoreConfig_SetArgv(
+ _PyCoreConfig *config,
+ int argc,
+ char **argv);
+PyAPI_FUNC(_PyInitError) _PyCoreConfig_SetWideArgv(_PyCoreConfig *config,
+ int argc,
+ wchar_t **argv);
+
/* --- Function used for testing ---------------------------------- */
def collect_get_config(info_add):
- # Dump global configuration variables, _PyCoreConfig
- # and _PyMainInterpreterConfig
+ # Get global configuration variables, _PyPreConfig and _PyCoreConfig
try:
from _testinternalcapi import get_configs
except ImportError:
static _PyInitError
-core_read_precmdline(_PyCoreConfig *config, const _PyArgv *args,
- _PyPreCmdline *precmdline)
+core_read_precmdline(_PyCoreConfig *config, _PyPreCmdline *precmdline)
{
_PyInitError err;
}
+_PyInitError
+_PyCoreConfig_SetPyArgv(_PyCoreConfig *config, const _PyArgv *args)
+{
+ return _PyArgv_AsWstrList(args, &config->argv);
+}
+
+
+_PyInitError
+_PyCoreConfig_SetArgv(_PyCoreConfig *config, int argc, char **argv)
+{
+ _PyArgv args = {
+ .argc = argc,
+ .use_bytes_argv = 1,
+ .bytes_argv = argv,
+ .wchar_argv = NULL};
+ return _PyCoreConfig_SetPyArgv(config, &args);
+}
+
+
+_PyInitError
+_PyCoreConfig_SetWideArgv(_PyCoreConfig *config, int argc, wchar_t **argv)
+{
+ _PyArgv args = {
+ .argc = argc,
+ .use_bytes_argv = 0,
+ .bytes_argv = NULL,
+ .wchar_argv = argv};
+ return _PyCoreConfig_SetPyArgv(config, &args);
+}
+
+
/* Read the configuration into _PyCoreConfig from:
* Command line arguments
* Environment variables
* Py_xxx global configuration variables */
_PyInitError
-_PyCoreConfig_Read(_PyCoreConfig *config, const _PyArgv *args)
+_PyCoreConfig_Read(_PyCoreConfig *config)
{
_PyInitError err;
- if (args) {
- err = _PyArgv_AsWstrList(args, &config->argv);
- if (_Py_INIT_FAILED(err)) {
- return err;
- }
- }
-
err = _Py_PreInitializeFromCoreConfig(config);
if (_Py_INIT_FAILED(err)) {
return err;
_PyCoreConfig_GetGlobalConfig(config);
_PyPreCmdline precmdline = _PyPreCmdline_INIT;
- err = core_read_precmdline(config, args, &precmdline);
+ err = core_read_precmdline(config, &precmdline);
if (_Py_INIT_FAILED(err)) {
goto done;
}
_PyInitError err;
_PyCoreConfig config = _PyCoreConfig_INIT;
- err = _PyCoreConfig_Read(&config, NULL);
+ err = _PyCoreConfig_Read(&config);
if (_Py_INIT_FAILED(err)) {
goto error;
}
const _PyArgv *args,
PyInterpreterState **interp_p)
{
+ _PyInitError err;
+
if (src_config) {
if (_PyCoreConfig_Copy(config, src_config) < 0) {
return _Py_INIT_NO_MEMORY();
}
}
- _PyInitError err = _PyCoreConfig_Read(config, args);
+ if (args) {
+ err = _PyCoreConfig_SetPyArgv(config, args);
+ if (_Py_INIT_FAILED(err)) {
+ return err;
+ }
+ }
+
+ err = _PyCoreConfig_Read(config);
if (_Py_INIT_FAILED(err)) {
return err;
}