Skip to content

Commit 410759f

Browse files
authored
bpo-36763: Remove _PyCoreConfig.dll_path (GH-13402)
1 parent bab0db6 commit 410759f

File tree

6 files changed

+15
-41
lines changed

6 files changed

+15
-41
lines changed

Include/cpython/coreconfig.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,6 @@ typedef struct {
353353
wchar_t *base_prefix; /* sys.base_prefix */
354354
wchar_t *exec_prefix; /* sys.exec_prefix */
355355
wchar_t *base_exec_prefix; /* sys.base_exec_prefix */
356-
#ifdef MS_WINDOWS
357-
wchar_t *dll_path; /* Windows DLL path */
358-
#endif
359356

360357
/* --- Parameter only used by Py_Main() ---------- */
361358

Include/internal/pycore_pathconfig.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ PyAPI_FUNC(int) _Py_FindEnvConfigValue(
5353
wchar_t *value,
5454
size_t value_size);
5555

56+
#ifdef MS_WINDOWS
57+
extern wchar_t* _Py_GetDLLPath(void);
58+
#endif
59+
5660
#ifdef __cplusplus
5761
}
5862
#endif

Lib/test/test_embed.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,6 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
369369
'legacy_windows_fs_encoding': 0,
370370
})
371371
DEFAULT_CORE_CONFIG.update({
372-
'dll_path': GET_DEFAULT_CONFIG,
373372
'legacy_windows_stdio': 0,
374373
})
375374

@@ -466,8 +465,6 @@ def get_expected_config(self, expected_preconfig, expected, env, api,
466465
'filesystem_errors': sys.getfilesystemencodeerrors(),
467466
'module_search_paths': core_config['module_search_paths'],
468467
}
469-
if sys.platform == 'win32':
470-
data['dll_path'] = core_config['dll_path']
471468
472469
data = json.dumps(data)
473470
data = data.encode('utf-8')

PC/getpathp.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -508,8 +508,8 @@ getpythonregpath(HKEY keyBase, int skipcore)
508508
#endif /* Py_ENABLE_SHARED */
509509

510510

511-
static _PyInitError
512-
get_dll_path(PyCalculatePath *calculate, _PyPathConfig *config)
511+
wchar_t*
512+
_Py_GetDLLPath(void)
513513
{
514514
wchar_t dll_path[MAXPATHLEN+1];
515515
memset(dll_path, 0, sizeof(dll_path));
@@ -525,11 +525,7 @@ get_dll_path(PyCalculatePath *calculate, _PyPathConfig *config)
525525
dll_path[0] = 0;
526526
#endif
527527

528-
config->dll_path = _PyMem_RawWcsdup(dll_path);
529-
if (config->dll_path == NULL) {
530-
return _Py_INIT_NO_MEMORY();
531-
}
532-
return _Py_INIT_OK();
528+
return _PyMem_RawWcsdup(dll_path);
533529
}
534530

535531

@@ -956,9 +952,11 @@ calculate_path_impl(const _PyCoreConfig *core_config,
956952
{
957953
_PyInitError err;
958954

959-
err = get_dll_path(calculate, config);
960-
if (_Py_INIT_FAILED(err)) {
961-
return err;
955+
assert(config->dll_path == NULL);
956+
957+
config->dll_path = _Py_GetDLLPath();
958+
if (config->dll_path == NULL) {
959+
return _Py_INIT_NO_MEMORY();
962960
}
963961

964962
err = get_program_full_path(core_config, calculate, config);

Python/coreconfig.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -531,9 +531,6 @@ _PyCoreConfig_Clear(_PyCoreConfig *config)
531531
CLEAR(config->prefix);
532532
CLEAR(config->base_prefix);
533533
CLEAR(config->exec_prefix);
534-
#ifdef MS_WINDOWS
535-
CLEAR(config->dll_path);
536-
#endif
537534
CLEAR(config->base_exec_prefix);
538535

539536
CLEAR(config->filesystem_encoding);
@@ -761,9 +758,6 @@ _PyCoreConfig_Copy(_PyCoreConfig *config, const _PyCoreConfig *config2)
761758
COPY_WSTR_ATTR(prefix);
762759
COPY_WSTR_ATTR(base_prefix);
763760
COPY_WSTR_ATTR(exec_prefix);
764-
#ifdef MS_WINDOWS
765-
COPY_WSTR_ATTR(dll_path);
766-
#endif
767761
COPY_WSTR_ATTR(base_exec_prefix);
768762

769763
COPY_ATTR(site_import);
@@ -864,9 +858,6 @@ _PyCoreConfig_AsDict(const _PyCoreConfig *config)
864858
SET_ITEM_WSTR(base_prefix);
865859
SET_ITEM_WSTR(exec_prefix);
866860
SET_ITEM_WSTR(base_exec_prefix);
867-
#ifdef MS_WINDOWS
868-
SET_ITEM_WSTR(dll_path);
869-
#endif
870861
SET_ITEM_INT(site_import);
871862
SET_ITEM_INT(bytes_warning);
872863
SET_ITEM_INT(inspect);
@@ -2355,9 +2346,6 @@ _PyCoreConfig_Read(_PyCoreConfig *config)
23552346
assert(config->base_prefix != NULL);
23562347
assert(config->exec_prefix != NULL);
23572348
assert(config->base_exec_prefix != NULL);
2358-
#ifdef MS_WINDOWS
2359-
assert(config->dll_path != NULL);
2360-
#endif
23612349
}
23622350
assert(config->filesystem_encoding != NULL);
23632351
assert(config->filesystem_errors != NULL);

Python/pathconfig.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ _PyCoreConfig_SetPathConfig(const _PyCoreConfig *core_config)
214214
goto no_memory;
215215
}
216216
#ifdef MS_WINDOWS
217-
if (copy_wstr(&path_config.dll_path, core_config->dll_path) < 0) {
217+
path_config.dll_path = _Py_GetDLLPath();
218+
if (path_config.dll_path == NULL) {
218219
goto no_memory;
219220
}
220221
#endif
@@ -322,14 +323,6 @@ _PyCoreConfig_CalculatePathConfig(_PyCoreConfig *config)
322323
}
323324
}
324325

325-
#ifdef MS_WINDOWS
326-
if (config->dll_path == NULL) {
327-
if (copy_wstr(&config->dll_path, path_config.dll_path) < 0) {
328-
goto no_memory;
329-
}
330-
}
331-
#endif
332-
333326
if (path_config.isolated != -1) {
334327
config->isolated = path_config.isolated;
335328
}
@@ -356,9 +349,6 @@ _PyCoreConfig_InitPathConfig(_PyCoreConfig *config)
356349
if (!config->use_module_search_paths
357350
|| (config->executable == NULL)
358351
|| (config->prefix == NULL)
359-
#ifdef MS_WINDOWS
360-
|| (config->dll_path == NULL)
361-
#endif
362352
|| (config->exec_prefix == NULL))
363353
{
364354
_PyInitError err = _PyCoreConfig_CalculatePathConfig(config);
@@ -435,7 +425,7 @@ Py_SetPath(const wchar_t *path)
435425
new_config.exec_prefix = _PyMem_RawWcsdup(L"");
436426
alloc_error |= (new_config.exec_prefix == NULL);
437427
#ifdef MS_WINDOWS
438-
new_config.dll_path = _PyMem_RawWcsdup(L"");
428+
new_config.dll_path = _Py_GetDLLPath();
439429
alloc_error |= (new_config.dll_path == NULL);
440430
#endif
441431
new_config.module_search_path = _PyMem_RawWcsdup(path);

0 commit comments

Comments
 (0)