bpo-32030: Rewrite _PyMainInterpreterConfig (#4854)

_PyMainInterpreterConfig now contains Python objects, whereas
_PyCoreConfig contains wchar_t* strings.

Core config:

* Rename _PyMainInterpreterConfig_ReadEnv() to _PyCoreConfig_ReadEnv()
* Move 3 strings from _PyMainInterpreterConfig to _PyCoreConfig:
  module_search_path_env, home, program_name.
* Add _PyCoreConfig_Clear()
* _PyPathConfig_Calculate() now takes core config rather than main
  config
* _PyMainInterpreterConfig_Read() now requires also a core config

Main config:

* Add _PyMainInterpreterConfig.module_search_path: sys.path list
* Add _PyMainInterpreterConfig.argv: sys.argv list
* _PyMainInterpreterConfig_Read() now computes module_search_path
This commit is contained in:
Victor Stinner 2017-12-14 02:20:52 +01:00 committed by GitHub
parent 176baa326b
commit b5fd9ad05e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 285 additions and 197 deletions

View file

@ -39,6 +39,11 @@ typedef struct {
int dump_refs; /* PYTHONDUMPREFS */
int malloc_stats; /* PYTHONMALLOCSTATS */
int utf8_mode; /* -X utf8 or PYTHONUTF8 environment variable */
wchar_t *module_search_path_env; /* PYTHONPATH environment variable */
wchar_t *home; /* PYTHONHOME environment variable,
see also Py_SetPythonHome(). */
wchar_t *program_name; /* Program name, see also Py_GetProgramName() */
} _PyCoreConfig;
#define _PyCoreConfig_INIT (_PyCoreConfig){.use_hash_seed = -1}
@ -52,12 +57,8 @@ typedef struct {
*/
typedef struct {
int install_signal_handlers;
/* PYTHONPATH environment variable */
wchar_t *module_search_path_env;
/* PYTHONHOME environment variable, see also Py_SetPythonHome(). */
wchar_t *home;
/* Program name, see also Py_GetProgramName() */
wchar_t *program_name;
PyObject *argv; /* sys.argv list, can be NULL */
PyObject *module_search_path; /* sys.path list */
} _PyMainInterpreterConfig;
#define _PyMainInterpreterConfig_INIT \