pythoninfo: log more environment variable (GH-10719) (GH-10769)

Log TZ to debug a timezone issue... and a few more :-)

(cherry picked from commit 282c03d45d)
This commit is contained in:
Victor Stinner 2018-11-28 18:04:30 +01:00 committed by GitHub
parent 9c16bc2c3d
commit c9010456d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 45 additions and 4 deletions

View File

@ -199,32 +199,73 @@ def collect_os(info_add):
call_func(info_add, 'os.cpu_count', os, 'cpu_count') call_func(info_add, 'os.cpu_count', os, 'cpu_count')
call_func(info_add, 'os.loadavg', os, 'getloadavg') call_func(info_add, 'os.loadavg', os, 'getloadavg')
# Get environment variables: filter to list # Environment variables used by the stdlib and tests. Don't log the full
# to not leak sensitive information # environment: filter to list to not leak sensitive information.
ENV_VARS = ( #
# HTTP_PROXY is not logged because it can contain a password.
ENV_VARS = frozenset((
"APPDATA",
"AR",
"ARCHFLAGS",
"ARFLAGS",
"AUDIODEV",
"CC", "CC",
"CFLAGS",
"COLUMNS",
"COMPUTERNAME",
"COMSPEC", "COMSPEC",
"CPP",
"CPPFLAGS",
"DISPLAY", "DISPLAY",
"DISTUTILS_DEBUG",
"DISTUTILS_USE_SDK", "DISTUTILS_USE_SDK",
"DYLD_LIBRARY_PATH", "DYLD_LIBRARY_PATH",
"ENSUREPIP_OPTIONS",
"HISTORY_FILE",
"HOME", "HOME",
"HOMEDRIVE", "HOMEDRIVE",
"HOMEPATH", "HOMEPATH",
"IDLESTARTUP",
"LANG", "LANG",
"LDFLAGS",
"LDSHARED",
"LD_LIBRARY_PATH", "LD_LIBRARY_PATH",
"LINES",
"MACOSX_DEPLOYMENT_TARGET", "MACOSX_DEPLOYMENT_TARGET",
"MAILCAPS",
"MAKEFLAGS", "MAKEFLAGS",
"MIXERDEV",
"MSSDK", "MSSDK",
"PATH", "PATH",
"PATHEXT",
"PIP_CONFIG_FILE",
"PLAT",
"POSIXLY_CORRECT",
"PY_SAX_PARSER",
"ProgramFiles",
"ProgramFiles(x86)",
"RUNNING_ON_VALGRIND",
"SDK_TOOLS_BIN", "SDK_TOOLS_BIN",
"SERVER_SOFTWARE",
"SHELL", "SHELL",
"SOURCE_DATE_EPOCH",
"SYSTEMROOT",
"TEMP", "TEMP",
"TERM", "TERM",
"TILE_LIBRARY",
"TIX_LIBRARY",
"TMP", "TMP",
"TMPDIR", "TMPDIR",
"TZ",
"USERPROFILE", "USERPROFILE",
"VIRTUAL_ENV",
"WAYLAND_DISPLAY", "WAYLAND_DISPLAY",
) "WINDIR",
"_PYTHON_HOST_PLATFORM",
"_PYTHON_PROJECT_BASE",
"_PYTHON_SYSCONFIGDATA_NAME",
"__PYVENV_LAUNCHER__",
))
for name, value in os.environ.items(): for name, value in os.environ.items():
uname = name.upper() uname = name.upper()
if (uname in ENV_VARS if (uname in ENV_VARS