66import re
77import sys
88import traceback
9+ import warnings
910
1011
1112def normalize_text (text ):
@@ -144,6 +145,10 @@ def collect_platform(info_add):
144145 info_add ('platform.platform' ,
145146 platform .platform (aliased = True ))
146147
148+ libc_ver = ('%s %s' % platform .libc_ver ()).strip ()
149+ if libc_ver :
150+ info_add ('platform.libc_ver' , libc_ver )
151+
147152
148153def collect_locale (info_add ):
149154 import locale
@@ -376,9 +381,17 @@ def collect_time(info_add):
376381 copy_attributes (info_add , time , 'time.%s' , attributes )
377382
378383 if hasattr (time , 'get_clock_info' ):
379- for clock in ('time' , 'perf_counter' ):
380- tinfo = time .get_clock_info (clock )
381- info_add ('time.get_clock_info(%s)' % clock , tinfo )
384+ for clock in ('clock' , 'monotonic' , 'perf_counter' ,
385+ 'process_time' , 'thread_time' , 'time' ):
386+ try :
387+ # prevent DeprecatingWarning on get_clock_info('clock')
388+ with warnings .catch_warnings (record = True ):
389+ clock_info = time .get_clock_info (clock )
390+ except ValueError :
391+ # missing clock like time.thread_time()
392+ pass
393+ else :
394+ info_add ('time.get_clock_info(%s)' % clock , clock_info )
382395
383396
384397def collect_datetime (info_add ):
@@ -558,10 +571,17 @@ def collect_cc(info_add):
558571 except ImportError :
559572 args = CC .split ()
560573 args .append ('--version' )
561- proc = subprocess .Popen (args ,
562- stdout = subprocess .PIPE ,
563- stderr = subprocess .STDOUT ,
564- universal_newlines = True )
574+ try :
575+ proc = subprocess .Popen (args ,
576+ stdout = subprocess .PIPE ,
577+ stderr = subprocess .STDOUT ,
578+ universal_newlines = True )
579+ except OSError :
580+ # Cannot run the compiler, for example when Python has been
581+ # cross-compiled and installed on the target platform where the
582+ # compiler is missing.
583+ return
584+
565585 stdout = proc .communicate ()[0 ]
566586 if proc .returncode :
567587 # CC --version failed: ignore error
@@ -585,18 +605,20 @@ def collect_get_config(info_add):
585605 # Dump global configuration variables, _PyCoreConfig
586606 # and _PyMainInterpreterConfig
587607 try :
588- from _testcapi import get_global_config , get_core_config , get_main_config
608+ from _testinternalcapi import get_configs
589609 except ImportError :
590610 return
591611
592- for prefix , get_config_func in (
593- ('global_config' , get_global_config ),
594- ('core_config' , get_core_config ),
595- ('main_config' , get_main_config ),
596- ):
597- config = get_config_func ()
612+ all_configs = get_configs ()
613+ for config_type in sorted (all_configs ):
614+ config = all_configs [config_type ]
598615 for key in sorted (config ):
599- info_add ('%s[%s]' % (prefix , key ), repr (config [key ]))
616+ info_add ('%s[%s]' % (config_type , key ), repr (config [key ]))
617+
618+
619+ def collect_subprocess (info_add ):
620+ import subprocess
621+ copy_attributes (info_add , subprocess , 'subprocess.%s' , ('_USE_POSIX_SPAWN' ,))
600622
601623
602624def collect_info (info ):
@@ -628,6 +650,7 @@ def collect_info(info):
628650 collect_cc ,
629651 collect_gdbm ,
630652 collect_get_config ,
653+ collect_subprocess ,
631654
632655 # Collecting from tests should be last as they have side effects.
633656 collect_test_socket ,
0 commit comments