8000 test.pythoninfo logs more build info (#93225) · python/cpython@06dd26f · GitHub
[go: up one dir, main page]

Skip to content

Commit 06dd26f

Browse files
authored
test.pythoninfo logs more build info (#93225)
Log also test.support.check_sanitizer() values.
1 parent cc37706 commit 06dd26f

File tree

1 file changed

+47
-3
lines changed

1 file changed

+47
-3
lines changed

Lib/test/pythoninfo.py

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
import warnings
1111

1212

13+
MS_WINDOWS = (sys.platform == 'win32')
14+
15+
1316
def normalize_text(text):
1417
if text is None:
1518
return None
@@ -127,13 +130,21 @@ def collect_sys(info_add):
127130
encoding = '%s/%s' % (encoding, errors)
128131
info_add('sys.%s.encoding' % name, encoding)
129132

130-
# Were we compiled --with-pydebug or with #define Py_DEBUG?
133+
# Were we compiled --with-pydebug?
131134
Py_DEBUG = hasattr(sys, 'gettotalrefcount')
132135
if Py_DEBUG:
133136
text = 'Yes (sys.gettotalrefcount() present)'
134137
else:
135138
text = 'No (sys.gettotalrefcount() missing)'
136-
info_add('Py_DEBUG', text)
139+
info_add('build.Py_DEBUG', text)
140+
141+
# Were we compiled --with-trace-refs?
142+
Py_TRACE_REFS = hasattr(sys, 'getobjects')
143+
if Py_TRACE_REFS:
144+
text = 'Yes (sys.getobjects() present)'
145+
else:
146+
text = 'No (sys.getobjects() missing)'
147+
info_add('build.Py_REF_DEBUG', text)
137148

138149

139150
def collect_platform(info_add):
@@ -455,6 +466,11 @@ def collect_datetime(info_add):
455466

456467

457468
def collect_sysconfig(info_add):
469+
# On Windows, sysconfig is not reliable to get macros used
470+
# to build Python
471+
if MS_WINDOWS:
472+
return
473+
458474
import sysconfig
459475

460476
for name in (
@@ -488,6 +504,28 @@ def collect_sysconfig(info_add):
488504
value = normalize_text(value)
489505
info_add('sysconfig[%s]' % name, value)
490506

507+
PY_CFLAGS = sysconfig.get_config_var('PY_CFLAGS')
508+
NDEBUG = (PY_CFLAGS and '-DNDEBUG' in PY_CFLAGS)
509+
if NDEBUG:
510+
text = 'ignore assertions (macro defined)'
511+
else:
512+
text= 'build assertions (macro not defined)'
513+
info_add('build.NDEBUG',text)
514+
515+
for name in (
516+
'WITH_DOC_STRINGS',
517+
'WITH_DTRACE',
518+
'WITH_FREELISTS',
519+
'WITH_PYMALLOC',
520+
'WITH_VALGRIND',
521+
):
522+
value = sysconfig.get_config_var(name)
523+
if value:
524+
text = 'Yes'
525+
else:
526+
text = 'No'
527+
info_add(f'build.{name}', text)
528+
491529

492530
def collect_ssl(info_add):
493531
import os
@@ -605,7 +643,6 @@ def collect_testcapi(info_add):
605643
return
606644

607645
call_func(info_add, 'pymem.allocator', _testcapi, 'pymem_getallocatorsname')
608-
copy_attr(info_add, 'pymem.with_pymalloc', _testcapi, 'WITH_PYMALLOC')
609646

610647

611648
def collect_resource(info_add):
@@ -647,6 +684,13 @@ def collect_test_support(info_add):
647684
call_func(info_add, 'test_support._is_gui_available', support, '_is_gui_available')
648685
call_func(info_add, 'test_support.python_is_optimized', support, 'python_is_optimized')
649686

687+
info_add('test_support.check_sanitizer(address=True)',
688+
support.check_sanitizer(address=True))
689+
info_add('test_support.check_sanitizer(memory=True)',
690+
support.check_sanitizer(memory=True))
691+
info_add('test_support.check_sanitizer(ub=True)',
692+
support.check_sanitizer(ub=True))
693+
650694

651695
def collect_cc(info_add):
652696
import subprocess

0 commit comments

Comments
 (0)
0