mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
bpo-45471: Do not set PyConfig.stdlib_dir in Py_SetPythonHome(). (gh-28954)
The change in gh-28586 (bpo-45211) should not have included code to set _Py_path_config.stdlib_dir in Py_SetPythonHome(). We fix that here. https://bugs.python.org/issue45471
This commit is contained in:
parent
3cc56c828d
commit
0bbea0723e
2 changed files with 7 additions and 5 deletions
|
@ -1247,6 +1247,11 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
||||||
self.fail(f"Unable to find home in {paths!r}")
|
self.fail(f"Unable to find home in {paths!r}")
|
||||||
|
|
||||||
prefix = exec_prefix = home
|
prefix = exec_prefix = home
|
||||||
|
if MS_WINDOWS:
|
||||||
|
stdlib = os.path.join(home, sys.platlibdir)
|
||||||
|
else:
|
||||||
|
version = f'{sys.version_info.major}.{sys.version_info.minor}'
|
||||||
|
stdlib = os.path.join(home, sys.platlibdir, f'python{version}')
|
||||||
expected_paths = self.module_search_paths(prefix=home, exec_prefix=home)
|
expected_paths = self.module_search_paths(prefix=home, exec_prefix=home)
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
|
@ -1257,7 +1262,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
||||||
'exec_prefix': exec_prefix,
|
'exec_prefix': exec_prefix,
|
||||||
'base_exec_prefix': exec_prefix,
|
'base_exec_prefix': exec_prefix,
|
||||||
'pythonpath_env': paths_str,
|
'pythonpath_env': paths_str,
|
||||||
'stdlib_dir': home,
|
'stdlib_dir': stdlib,
|
||||||
}
|
}
|
||||||
self.default_program_name(config)
|
self.default_program_name(config)
|
||||||
env = {'TESTHOME': home, 'PYTHONPATH': paths_str}
|
env = {'TESTHOME': home, 'PYTHONPATH': paths_str}
|
||||||
|
|
|
@ -530,13 +530,10 @@ Py_SetPythonHome(const wchar_t *home)
|
||||||
|
|
||||||
PyMem_RawFree(_Py_path_config.home);
|
PyMem_RawFree(_Py_path_config.home);
|
||||||
_Py_path_config.home = _PyMem_RawWcsdup(home);
|
_Py_path_config.home = _PyMem_RawWcsdup(home);
|
||||||
if (_Py_path_config.home != NULL) {
|
|
||||||
_Py_path_config.stdlib_dir = _PyMem_RawWcsdup(home);
|
|
||||||
}
|
|
||||||
|
|
||||||
PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
|
PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
|
||||||
|
|
||||||
if (_Py_path_config.home == NULL || _Py_path_config.stdlib_dir == NULL) {
|
if (_Py_path_config.home == NULL) {
|
||||||
path_out_of_memory(__func__);
|
path_out_of_memory(__func__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue