From b1147e43daeb3c51a63056b489e8d868404d4e22 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Sat, 21 Jul 2018 02:06:16 +0200 Subject: bpo-34170: Rework _PyCoreConfig_Read() to avoid side effect (GH-8353) Rework _PyCoreConfig_Read() function which *reads* core configuration to not *modify* the path configuration. A new _PyCoreConfig_SetPathConfig() function now recreates the path configuration from the core configuration. This function is now called very late in _Py_InitializeCore(), just before calling initimport(). Changes: * Add _PyCoreConfig.dll_path * Py_SetPath() now fails with a fatal python error on memory allocation failure. * Rename _PyPathConfig_Calculate() to _PyPathConfig_Calculate_impl() * Replace _PyPathConfig_Init() with _PyPathConfig_Calculate(): the function now requires a _PyPathConfig * Add _PyPathConfig_SetGlobal() to set the _Py_path_config global variable. * Add _PyCoreConfig_InitPathConfig(): compute the path configuration * Add _PyCoreConfig_SetPathConfig(): set path configuration from core configuration * Rename wstrlist_append() to _Py_wstrlist_append() * _Py_wstrlist_append() now handles integer overflow. --- Modules/getpath.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Modules/getpath.c') diff --git a/Modules/getpath.c b/Modules/getpath.c index 755298eb4b..6d966e1bce 100644 --- a/Modules/getpath.c +++ b/Modules/getpath.c @@ -946,7 +946,7 @@ calculate_path_impl(const _PyCoreConfig *core_config, _PyInitError -_PyPathConfig_Calculate(_PyPathConfig *config, const _PyCoreConfig *core_config) +_PyPathConfig_Calculate_impl(_PyPathConfig *config, const _PyCoreConfig *core_config) { PyCalculatePath calculate; memset(&calculate, 0, sizeof(calculate)); -- cgit v1.2.1