summaryrefslogtreecommitdiffstats
path: root/Python/initconfig.c
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2021-09-28 18:18:28 (GMT)
committerGitHub <noreply@github.com>2021-09-28 18:18:28 (GMT)
commit0c50b8c0b8274d54d6b71ed7bd21057d3642f138 (patch)
treeed77a5e7e69302e88349da50c5473c1aa7397d00 /Python/initconfig.c
parent84975146a7ce64f1d50dcec8311b7f7188a5c962 (diff)
downloadcpython-0c50b8c0b8274d54d6b71ed7bd21057d3642f138.zip
cpython-0c50b8c0b8274d54d6b71ed7bd21057d3642f138.tar.gz
cpython-0c50b8c0b8274d54d6b71ed7bd21057d3642f138.tar.bz2
bpo-45211: Remember the stdlib dir during startup. (gh-28586)
During runtime startup we figure out the stdlib dir but currently throw that information away. This change preserves it and exposes it via PyConfig.stdlib_dir, _Py_GetStdlibDir(), and sys._stdlib_dir. https://bugs.python.org/issue45211
Diffstat (limited to 'Python/initconfig.c')
-rw-r--r--Python/initconfig.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Python/initconfig.c b/Python/initconfig.c
index 40a5846..9fa202a 100644
--- a/Python/initconfig.c
+++ b/Python/initconfig.c
@@ -669,6 +669,7 @@ PyConfig_Clear(PyConfig *config)
_PyWideStringList_Clear(&config->xoptions);
_PyWideStringList_Clear(&config->module_search_paths);
config->module_search_paths_set = 0;
+ CLEAR(config->stdlib_dir);
CLEAR(config->executable);
CLEAR(config->base_executable);
@@ -909,6 +910,7 @@ _PyConfig_Copy(PyConfig *config, const PyConfig *config2)
COPY_WSTRLIST(xoptions);
COPY_WSTRLIST(module_search_paths);
COPY_ATTR(module_search_paths_set);
+ COPY_WSTR_ATTR(stdlib_dir);
COPY_WSTR_ATTR(executable);
COPY_WSTR_ATTR(base_executable);
@@ -1015,6 +1017,7 @@ _PyConfig_AsDict(const PyConfig *config)
SET_ITEM_WSTR(home);
SET_ITEM_INT(module_search_paths_set);
SET_ITEM_WSTRLIST(module_search_paths);
+ SET_ITEM_WSTR(stdlib_dir);
SET_ITEM_WSTR(executable);
SET_ITEM_WSTR(base_executable);
SET_ITEM_WSTR(prefix);
@@ -1318,6 +1321,7 @@ _PyConfig_FromDict(PyConfig *config, PyObject *dict)
// Path configuration output
GET_UINT(module_search_paths_set);
GET_WSTRLIST(module_search_paths);
+ GET_WSTR_OPT(stdlib_dir);
GET_WSTR_OPT(executable);
GET_WSTR_OPT(base_executable);
GET_WSTR_OPT(prefix);
@@ -3094,6 +3098,7 @@ _Py_DumpPathConfig(PyThreadState *tstate)
PySys_WriteStderr(" environment = %i\n", config->use_environment);
PySys_WriteStderr(" user site = %i\n", config->user_site_directory);
PySys_WriteStderr(" import site = %i\n", config->site_import);
+ DUMP_CONFIG("stdlib dir", stdlib_dir);
#undef DUMP_CONFIG
#define DUMP_SYS(NAME) \