]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
test.pythoninfo logs freedesktop_os_release() (#109057)
authorVictor Stinner <vstinner@python.org>
Thu, 7 Sep 2023 05:43:32 +0000 (07:43 +0200)
committerGitHub <noreply@github.com>
Thu, 7 Sep 2023 05:43:32 +0000 (05:43 +0000)
Lib/test/pythoninfo.py

index 46522b50dd1e985a1eecdf3a786287e35ddd8614..c628833478044e948a24e1f38b0f0fd3ab5089bb 100644 (file)
@@ -164,6 +164,26 @@ def collect_platform(info_add):
     if libc_ver:
         info_add('platform.libc_ver', libc_ver)
 
+    try:
+        os_release = platform.freedesktop_os_release()
+    except OSError:
+        pass
+    else:
+        for key in (
+            'ID',
+            'NAME',
+            'PRETTY_NAME'
+            'VARIANT',
+            'VARIANT_ID',
+            'VERSION',
+            'VERSION_CODENAME',
+            'VERSION_ID',
+        ):
+            if key not in os_release:
+                continue
+            info_add(f'platform.freedesktop_os_release[{key}]',
+                     os_release[key])
+
 
 def collect_locale(info_add):
     import locale
@@ -920,7 +940,6 @@ def dump_info(info, file=None):
     for key, value in infos:
         value = value.replace("\n", " ")
         print("%s: %s" % (key, value))
-    print()
 
 
 def main():
@@ -929,6 +948,7 @@ def main():
     dump_info(info)
 
     if error:
+        print()
         print("Collection failed: exit with error", file=sys.stderr)
         sys.exit(1)