6
6
import re
7
7
import sys
8
8
import traceback
9
+ import warnings
9
10
10
11
11
12
def normalize_text (text ):
@@ -144,6 +145,10 @@ def collect_platform(info_add):
144
145
info_add ('platform.platform' ,
145
146
platform .platform (aliased = True ))
146
147
148
+ libc_ver = ('%s %s' % platform .libc_ver ()).strip ()
149
+ if libc_ver :
150
+ info_add ('platform.libc_ver' , libc_ver )
151
+
147
152
148
153
def collect_locale (info_add ):
149
154
import locale
@@ -376,9 +381,17 @@ def collect_time(info_add):
376
381
copy_attributes (info_add , time , 'time.%s' , attributes )
377
382
378
383
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 )
382
395
383
396
384
397
def collect_datetime (info_add ):
@@ -558,10 +571,17 @@ def collect_cc(info_add):
558
571
except ImportError :
559
572
args = CC .split ()
560
573
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
+
565
585
stdout = proc .communicate ()[0 ]
566
586
if proc .returncode :
567
587
# CC --version failed: ignore error
@@ -585,18 +605,20 @@ def collect_get_config(info_add):
585
605
# Dump global configuration variables, _PyCoreConfig
586
606
# and _PyMainInterpreterConfig
587
607
try :
588
- from _testcapi import get_global_config , get_core_config , get_main_config
608
+ from _testinternalcapi import get_configs
589
609
except ImportError :
590
610
return
591
611
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 ]
598
615
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' ,))
600
622
601
623
602
624
def collect_info (info ):
@@ -628,6 +650,7 @@ def collect_info(info):
628
650
collect_cc ,
629
651
collect_gdbm ,
630
652
collect_get_config ,
653
+ collect_subprocess ,
631
654
632
655
# Collecting from tests should be last as they have side effects.
633
656
collect_test_socket ,
0 commit comments