Commit 410759fb authored by Victor Stinner's avatar Victor Stinner Committed by GitHub

bpo-36763: Remove _PyCoreConfig.dll_path (GH-13402)

parent bab0db60
...@@ -353,9 +353,6 @@ typedef struct { ...@@ -353,9 +353,6 @@ typedef struct {
wchar_t *base_prefix; /* sys.base_prefix */ wchar_t *base_prefix; /* sys.base_prefix */
wchar_t *exec_prefix; /* sys.exec_prefix */ wchar_t *exec_prefix; /* sys.exec_prefix */
wchar_t *base_exec_prefix; /* sys.base_exec_prefix */ wchar_t *base_exec_prefix; /* sys.base_exec_prefix */
#ifdef MS_WINDOWS
wchar_t *dll_path; /* Windows DLL path */
#endif
/* --- Parameter only used by Py_Main() ---------- */ /* --- Parameter only used by Py_Main() ---------- */
......
...@@ -53,6 +53,10 @@ PyAPI_FUNC(int) _Py_FindEnvConfigValue( ...@@ -53,6 +53,10 @@ PyAPI_FUNC(int) _Py_FindEnvConfigValue(
wchar_t *value, wchar_t *value,
size_t value_size); size_t value_size);
#ifdef MS_WINDOWS
extern wchar_t* _Py_GetDLLPath(void);
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -369,7 +369,6 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase): ...@@ -369,7 +369,6 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
'legacy_windows_fs_encoding': 0, 'legacy_windows_fs_encoding': 0,
}) })
DEFAULT_CORE_CONFIG.update({ DEFAULT_CORE_CONFIG.update({
'dll_path': GET_DEFAULT_CONFIG,
'legacy_windows_stdio': 0, 'legacy_windows_stdio': 0,
}) })
...@@ -466,8 +465,6 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase): ...@@ -466,8 +465,6 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
'filesystem_errors': sys.getfilesystemencodeerrors(), 'filesystem_errors': sys.getfilesystemencodeerrors(),
'module_search_paths': core_config['module_search_paths'], 'module_search_paths': core_config['module_search_paths'],
} }
if sys.platform == 'win32':
data['dll_path'] = core_config['dll_path']
data = json.dumps(data) data = json.dumps(data)
data = data.encode('utf-8') data = data.encode('utf-8')
......
...@@ -508,8 +508,8 @@ done: ...@@ -508,8 +508,8 @@ done:
#endif /* Py_ENABLE_SHARED */ #endif /* Py_ENABLE_SHARED */
static _PyInitError wchar_t*
get_dll_path(PyCalculatePath *calculate, _PyPathConfig *config) _Py_GetDLLPath(void)
{ {
wchar_t dll_path[MAXPATHLEN+1]; wchar_t dll_path[MAXPATHLEN+1];
memset(dll_path, 0, sizeof(dll_path)); memset(dll_path, 0, sizeof(dll_path));
...@@ -525,11 +525,7 @@ get_dll_path(PyCalculatePath *calculate, _PyPathConfig *config) ...@@ -525,11 +525,7 @@ get_dll_path(PyCalculatePath *calculate, _PyPathConfig *config)
dll_path[0] = 0; dll_path[0] = 0;
#endif #endif
config->dll_path = _PyMem_RawWcsdup(dll_path); return _PyMem_RawWcsdup(dll_path);
if (config->dll_path == NULL) {
return _Py_INIT_NO_MEMORY();
}
return _Py_INIT_OK();
} }
...@@ -956,9 +952,11 @@ calculate_path_impl(const _PyCoreConfig *core_config, ...@@ -956,9 +952,11 @@ calculate_path_impl(const _PyCoreConfig *core_config,
{ {
_PyInitError err; _PyInitError err;
err = get_dll_path(calculate, config); assert(config->dll_path == NULL);
if (_Py_INIT_FAILED(err)) {
return err; config->dll_path = _Py_GetDLLPath();
if (config->dll_path == NULL) {
return _Py_INIT_NO_MEMORY();
} }
err = get_program_full_path(core_config, calculate, config); err = get_program_full_path(core_config, calculate, config);
......
...@@ -531,9 +531,6 @@ _PyCoreConfig_Clear(_PyCoreConfig *config) ...@@ -531,9 +531,6 @@ _PyCoreConfig_Clear(_PyCoreConfig *config)
CLEAR(config->prefix); CLEAR(config->prefix);
CLEAR(config->base_prefix); CLEAR(config->base_prefix);
CLEAR(config->exec_prefix); CLEAR(config->exec_prefix);
#ifdef MS_WINDOWS
CLEAR(config->dll_path);
#endif
CLEAR(config->base_exec_prefix); CLEAR(config->base_exec_prefix);
CLEAR(config->filesystem_encoding); CLEAR(config->filesystem_encoding);
...@@ -761,9 +758,6 @@ _PyCoreConfig_Copy(_PyCoreConfig *config, const _PyCoreConfig *config2) ...@@ -761,9 +758,6 @@ _PyCoreConfig_Copy(_PyCoreConfig *config, const _PyCoreConfig *config2)
COPY_WSTR_ATTR(prefix); COPY_WSTR_ATTR(prefix);
COPY_WSTR_ATTR(base_prefix); COPY_WSTR_ATTR(base_prefix);
COPY_WSTR_ATTR(exec_prefix); COPY_WSTR_ATTR(exec_prefix);
#ifdef MS_WINDOWS
COPY_WSTR_ATTR(dll_path);
#endif
COPY_WSTR_ATTR(base_exec_prefix); COPY_WSTR_ATTR(base_exec_prefix);
COPY_ATTR(site_import); COPY_ATTR(site_import);
...@@ -864,9 +858,6 @@ _PyCoreConfig_AsDict(const _PyCoreConfig *config) ...@@ -864,9 +858,6 @@ _PyCoreConfig_AsDict(const _PyCoreConfig *config)
SET_ITEM_WSTR(base_prefix); SET_ITEM_WSTR(base_prefix);
SET_ITEM_WSTR(exec_prefix); SET_ITEM_WSTR(exec_prefix);
SET_ITEM_WSTR(base_exec_prefix); SET_ITEM_WSTR(base_exec_prefix);
#ifdef MS_WINDOWS
SET_ITEM_WSTR(dll_path);
#endif
SET_ITEM_INT(site_import); SET_ITEM_INT(site_import);
SET_ITEM_INT(bytes_warning); SET_ITEM_INT(bytes_warning);
SET_ITEM_INT(inspect); SET_ITEM_INT(inspect);
...@@ -2355,9 +2346,6 @@ _PyCoreConfig_Read(_PyCoreConfig *config) ...@@ -2355,9 +2346,6 @@ _PyCoreConfig_Read(_PyCoreConfig *config)
assert(config->base_prefix != NULL); assert(config->base_prefix != NULL);
assert(config->exec_prefix != NULL); assert(config->exec_prefix != NULL);
assert(config->base_exec_prefix != NULL); assert(config->base_exec_prefix != NULL);
#ifdef MS_WINDOWS
assert(config->dll_path != NULL);
#endif
} }
assert(config->filesystem_encoding != NULL); assert(config->filesystem_encoding != NULL);
assert(config->filesystem_errors != NULL); assert(config->filesystem_errors != NULL);
......
...@@ -214,7 +214,8 @@ _PyCoreConfig_SetPathConfig(const _PyCoreConfig *core_config) ...@@ -214,7 +214,8 @@ _PyCoreConfig_SetPathConfig(const _PyCoreConfig *core_config)
goto no_memory; goto no_memory;
} }
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
if (copy_wstr(&path_config.dll_path, core_config->dll_path) < 0) { path_config.dll_path = _Py_GetDLLPath();
if (path_config.dll_path == NULL) {
goto no_memory; goto no_memory;
} }
#endif #endif
...@@ -322,14 +323,6 @@ _PyCoreConfig_CalculatePathConfig(_PyCoreConfig *config) ...@@ -322,14 +323,6 @@ _PyCoreConfig_CalculatePathConfig(_PyCoreConfig *config)
} }
} }
#ifdef MS_WINDOWS
if (config->dll_path == NULL) {
if (copy_wstr(&config->dll_path, path_config.dll_path) < 0) {
goto no_memory;
}
}
#endif
if (path_config.isolated != -1) { if (path_config.isolated != -1) {
config->isolated = path_config.isolated; config->isolated = path_config.isolated;
} }
...@@ -356,9 +349,6 @@ _PyCoreConfig_InitPathConfig(_PyCoreConfig *config) ...@@ -356,9 +349,6 @@ _PyCoreConfig_InitPathConfig(_PyCoreConfig *config)
if (!config->use_module_search_paths if (!config->use_module_search_paths
|| (config->executable == NULL) || (config->executable == NULL)
|| (config->prefix == NULL) || (config->prefix == NULL)
#ifdef MS_WINDOWS
|| (config->dll_path == NULL)
#endif
|| (config->exec_prefix == NULL)) || (config->exec_prefix == NULL))
{ {
_PyInitError err = _PyCoreConfig_CalculatePathConfig(config); _PyInitError err = _PyCoreConfig_CalculatePathConfig(config);
...@@ -435,7 +425,7 @@ Py_SetPath(const wchar_t *path) ...@@ -435,7 +425,7 @@ Py_SetPath(const wchar_t *path)
new_config.exec_prefix = _PyMem_RawWcsdup(L""); new_config.exec_prefix = _PyMem_RawWcsdup(L"");
alloc_error |= (new_config.exec_prefix == NULL); alloc_error |= (new_config.exec_prefix == NULL);
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
new_config.dll_path = _PyMem_RawWcsdup(L""); new_config.dll_path = _Py_GetDLLPath();
alloc_error |= (new_config.dll_path == NULL); alloc_error |= (new_config.dll_path == NULL);
#endif #endif
new_config.module_search_path = _PyMem_RawWcsdup(path); new_config.module_search_path = _PyMem_RawWcsdup(path);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment