summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-12-02 09:11:32 (GMT)
committerGitHub <noreply@github.com>2017-12-02 09:11:32 (GMT)
commitaf5a895073c24637c094772b27526b94a12ec897 (patch)
tree2960347bdeb6d0ba50746d5d36630d13630f1bb9 /Include
parente23c06e2b03452c9aaf0dae52296c85e572f9bcd (diff)
downloadcpython-af5a895073c24637c094772b27526b94a12ec897.zip
cpython-af5a895073c24637c094772b27526b94a12ec897.tar.gz
cpython-af5a895073c24637c094772b27526b94a12ec897.tar.bz2
bpo-32030: _PyPathConfig_Init() sets home and program_name (#4673)
_PyPathConfig_Init() now also initialize home and program_name: * Rename existing _PyPathConfig_Init() to _PyPathConfig_Calculate(). Add a new _PyPathConfig_Init() function in pathconfig.c which handles the _Py_path_config variable and call _PyPathConfig_Calculate(). * Add home and program_name fields to _PyPathConfig.home * _PyPathConfig_Init() now initialize home and program_name from main_config * Py_SetProgramName(), Py_SetPythonHome() and Py_GetPythonHome() now calls Py_FatalError() on failure, instead of silently ignoring failures. * config_init_home() now gets directly _Py_path_config.home to only get the value set by Py_SetPythonHome(), or NULL if Py_SetPythonHome() was not called. * config_get_program_name() now gets directly _Py_path_config.program_name to only get the value set by Py_SetProgramName(), or NULL if Py_SetProgramName() was not called. * pymain_init_python() doesn't call Py_SetProgramName() anymore, _PyPathConfig_Init() now always sets the program name * Call _PyMainInterpreterConfig_Read() in pymain_parse_cmdline_envvars_impl() to control the memory allocator * C API documentation: it's no more safe to call Py_GetProgramName() before Py_Initialize().
Diffstat (limited to 'Include')
-rw-r--r--Include/internal/pystate.h25
-rw-r--r--Include/pystate.h3
2 files changed, 26 insertions, 2 deletions
diff --git a/Include/internal/pystate.h b/Include/internal/pystate.h
index 9d85319..b933421 100644
--- a/Include/internal/pystate.h
+++ b/Include/internal/pystate.h
@@ -48,12 +48,35 @@ typedef struct {
#endif
/* Set by Py_SetPath(), or computed by _PyPathConfig_Init() */
wchar_t *module_search_path;
+ /* Python program name */
+ wchar_t *program_name;
+ /* Set by Py_SetPythonHome() or PYTHONHOME environment variable */
+ wchar_t *home;
} _PyPathConfig;
-#define _PyPathConfig_INIT {.module_search_path = NULL}
+#ifdef MS_WINDOWS
+#define _PyPathConfig_INIT \
+ {.program_full_path = NULL, \
+ .prefix = NULL, \
+ .dll_path = NULL, \
+ .module_search_path = NULL, \
+ .program_name = NULL, \
+ .home = NULL}
+#else
+#define _PyPathConfig_INIT \
+ {.program_full_path = NULL, \
+ .prefix = NULL, \
+ .exec_prefix = NULL, \
+ .module_search_path = NULL, \
+ .program_name = NULL, \
+ .home = NULL}
+#endif
PyAPI_DATA(_PyPathConfig) _Py_path_config;
+PyAPI_FUNC(_PyInitError) _PyPathConfig_Calculate(
+ _PyPathConfig *config,
+ const _PyMainInterpreterConfig *main_config);
PyAPI_FUNC(void) _PyPathConfig_Clear(_PyPathConfig *config);
diff --git a/Include/pystate.h b/Include/pystate.h
index 60d001c..1d8aab6 100644
--- a/Include/pystate.h
+++ b/Include/pystate.h
@@ -72,7 +72,8 @@ typedef struct {
(_PyMainInterpreterConfig){\
.install_signal_handlers = -1, \
.module_search_path_env = NULL, \
- .home = NULL}
+ .home = NULL, \
+ .program_name = NULL}
typedef struct _is {