mirror of
https://github.com/python/cpython.git
synced 2025-08-10 03:49:18 +00:00
[3.12] test.pythoninfo logs freedesktop_os_release() (GH-109057) (#109064)
test.pythoninfo logs freedesktop_os_release() (GH-109057)
(cherry picked from commit babdced23f
)
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
2979cee1af
commit
8c9f5f714e
1 changed files with 21 additions and 1 deletions
|
@ -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
|
||||
|
@ -913,7 +933,6 @@ def dump_info(info, file=None):
|
|||
for key, value in infos:
|
||||
value = value.replace("\n", " ")
|
||||
print("%s: %s" % (key, value))
|
||||
print()
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -922,6 +941,7 @@ def main():
|
|||
dump_info(info)
|
||||
|
||||
if error:
|
||||
print()
|
||||
print("Collection failed: exit with error", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue