bpo-39459: test.pythoninfo logs effective uid/gid (GH-18203)

Fix also umask formatting: use octal prefix.
This commit is contained in:
Victor Stinner 2020-01-27 18:06:42 +01:00 committed by GitHub
parent 9e1ed518a5
commit 4a46adc774
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 9 deletions

View File

@ -199,11 +199,19 @@ def collect_os(info_add):
)
copy_attributes(info_add, os, 'os.%s', attributes, formatter=format_attr)
call_func(info_add, 'os.getcwd', os, 'getcwd')
call_func(info_add, 'os.getuid', os, 'getuid')
call_func(info_add, 'os.getgid', os, 'getgid')
call_func(info_add, 'os.uname', os, 'uname')
for func in (
'cpu_count',
'getcwd',
'getegid',
'geteuid',
'getgid',
'getloadavg',
'getresgid',
'getresuid',
'getuid',
'uname',
):
call_func(info_add, 'os.%s' % func, os, func)
def format_groups(groups):
return ', '.join(map(str, groups))
@ -220,9 +228,6 @@ def collect_os(info_add):
else:
info_add("os.login", login)
call_func(info_add, 'os.cpu_count', os, 'cpu_count')
call_func(info_add, 'os.getloadavg', os, 'getloadavg')
# Environment variables used by the stdlib and tests. Don't log the full
# environment: filter to list to not leak sensitive information.
#
@ -303,7 +308,7 @@ def collect_os(info_add):
if hasattr(os, 'umask'):
mask = os.umask(0)
os.umask(mask)
info_add("os.umask", '%03o' % mask)
info_add("os.umask", '0o%03o' % mask)
def collect_pwd(info_add):