8000 bpo-45471: Do not set PyConfig.stdlib_dir in Py_SetPythonHome(). (gh-… · python/cpython@0bbea07 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0bbea07

Browse files
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
1 parent 3cc56c8 commit 0bbea07

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Lib/test/test_embed.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,11 @@ def test_init_setpythonhome(self):
12471247
self.fail(f"Unable to find home in {paths!r}")
12481248

12491249
prefix = exec_prefix = home
1250+
if MS_WINDOWS:
1251+
stdlib = os.path.join(home, sys.platlibdir)
1252+
else:
1253+
version = f'{sys.version_info.major}.{sys.version_info.minor}'
1254+
stdlib = os.path.join(home, sys.platlibdir, f'python{version}')
12501255
expected_paths = self.module_search_paths(prefix=home, exec_prefix=home)
12511256

12521257
config = {
@@ -1257,7 +1262,7 @@ def test_init_setpythonhome(self):
12571262
'exec_prefix': exec_prefix,
12581263
'base_exec_prefix': exec_prefix,
12591264
'pythonpath_env': paths_str,
1260-
'stdlib_dir': home,
1265+
'stdlib_dir': stdlib,
12611266
}
12621267
self.default_program_name(config)
12631268
env = {'TESTHOME': home, 'PYTHONPATH': paths_str}

Python/pathconfig.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -530,13 +530,10 @@ Py_SetPythonHome(const wchar_t *home)
530530

531531
PyMem_RawFree(_Py_path_config.home);
532532
_Py_path_config.home = _PyMem_RawWcsdup(home);
533-
if (_Py_path_config.home != NULL) {
534-
_Py_path_config.stdlib_dir = _PyMem_RawWcsdup(home);
535-
}
536533

537534
PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
538535

539-
if (_Py_path_config.home == NULL || _Py_path_config.stdlib_dir == NULL) {
536+
if (_Py_path_config.home == NULL) {
540537
path_out_of_memory(__func__);
541538
}
542539
}

0 commit comments

Comments
 (0)
0