From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Thu, 7 Sep 2023 06:13:34 +0000 (-0700) Subject: [3.11] test.pythoninfo logs freedesktop_os_release() (GH-109057) (#109063) X-Git-Tag: v3.11.6~128 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=883ff44f0d370d1f7c48bada494e0b34effa3019;p=thirdparty%2FPython%2Fcpython.git [3.11] test.pythoninfo logs freedesktop_os_release() (GH-109057) (#109063) test.pythoninfo logs freedesktop_os_release() (GH-109057) (cherry picked from commit babdced23fc299b7607ac76abfdd7a81050f8359) Co-authored-by: Victor Stinner --- diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py index 2575a9ae9e55..7a9c01b8c74a 100644 --- a/Lib/test/pythoninfo.py +++ b/Lib/test/pythoninfo.py @@ -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 @@ -921,7 +941,6 @@ def dump_info(info, file=None): for key, value in infos: value = value.replace("\n", " ") print("%s: %s" % (key, value)) - print() def main(): @@ -930,6 +949,7 @@ def main(): dump_info(info) if error: + print() print("Collection failed: exit with error", file=sys.stderr) sys.exit(1)