summaryrefslogtreecommitdiffstats
path: root/Python/sysmodule.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/sysmodule.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/sysmodule.c')
-rw-r--r--Python/sysmodule.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 5dfa917..6e7e45b 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -2974,6 +2974,14 @@ _PySys_UpdateConfig(PyThreadState *tstate)
SET_SYS("_xoptions", sys_create_xoptions_dict(config));
+ const wchar_t *stdlibdir = _Py_GetStdlibDir();
+ if (stdlibdir != NULL) {
+ SET_SYS_FROM_WSTR("_stdlib_dir", stdlibdir);
+ }
+ else {
+ PyDict_SetItemString(sysdict, "_stdlib_dir", Py_None);
+ }
+
#undef SET_SYS_FROM_WSTR
#undef COPY_LIST
#undef COPY_WSTR