Skip to content

Commit babdced

Browse files
authored
test.pythoninfo logs freedesktop_os_release() (#109057)
1 parent e7d5433 commit babdced

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

Lib/test/pythoninfo.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,26 @@ def collect_platform(info_add):
164164
if libc_ver:
165165
info_add('platform.libc_ver', libc_ver)
166166

167+
try:
168+
os_release = platform.freedesktop_os_release()
169+
except OSError:
170+
pass
171+
else:
172+
for key in (
173+
'ID',
174+
'NAME',
175+
'PRETTY_NAME'
176+
'VARIANT',
177+
'VARIANT_ID',
178+
'VERSION',
179+
'VERSION_CODENAME',
180+
'VERSION_ID',
181+
):
182+
if key not in os_release:
183+
continue
184+
info_add(f'platform.freedesktop_os_release[{key}]',
185+
os_release[key])
186+
167187

168188
def collect_locale(info_add):
169189
import locale
@@ -920,7 +940,6 @@ def dump_info(info, file=None):
920940
for key, value in infos:
921941
value = value.replace("\n", " ")
922942
print("%s: %s" % (key, value))
923-
print()
924943

925944

926945
def main():
@@ -929,6 +948,7 @@ def main():
929948
dump_info(info)
930949

931950
if error:
951+
print()
932952
print("Collection failed: exit with error", file=sys.stderr)
933953
sys.exit(1)
934954

0 commit comments

Comments
 (0)