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

Victor Stinner webhook-mailer at python.org
Mon Jan 27 12:06:47 EST 2020


https://github.com/python/cpython/commit/4a46adc7746930c4589ee483cad88d3f8504c045
commit: 4a46adc7746930c4589ee483cad88d3f8504c045
branch: master
author: Victor Stinner <vstinner at python.org>
committer: GitHub <noreply at github.com>
date: 2020-01-27T18:06:42+01:00
summary:

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

Fix also umask formatting: use octal prefix.

files:
M Lib/test/pythoninfo.py

diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py
index eab82c3631fd2..cc230dd2297a0 100644
--- a/Lib/test/pythoninfo.py
+++ b/Lib/test/pythoninfo.py
@@ -199,11 +199,19 @@ def format_attr(attr, value):
     )
     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 format_groups(groups):
         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 format_groups(groups):
     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):



More information about the Python-checkins mailing list