From 4a46adc7746930c4589ee483cad88d3f8504c045 Mon Sep 17 00:00:00 2001
From: Victor Stinner <vstinner@python.org>
Date: Mon, 27 Jan 2020 18:06:42 +0100
Subject: bpo-39459: test.pythoninfo logs effective uid/gid (GH-18203)

Fix also umask formatting: use octal prefix.
---
 Lib/test/pythoninfo.py | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py
index eab82c3..cc230dd 100644
--- a/Lib/test/pythoninfo.py
+++ b/Lib/test/pythoninfo.py
@@ -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):
-- 
cgit v0.12