Skip to content

Commit 561c709

Browse files
miss-islingtonvstinnerJelleZijlstra
authored
test.pythoninfo logs more build info (GH-93225) (#93256)
Log also test.support.check_sanitizer() values. (cherry picked from commit 06dd26f) Co-authored-by: Victor Stinner <[email protected]> Co-authored-by: Victor Stinner <[email protected]> Co-authored-by: Jelle Zijlstra <[email protected]>
1 parent 738c730 commit 561c709

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
@@ -9,6 +9,9 @@
99
import warnings
1010

1111

12+
MS_WINDOWS = (sys.platform == 'win32')
13+
14+
1215
def normalize_text(text):
1316
if text is None:
1417
return None
@@ -125,13 +128,21 @@ def collect_sys(info_add):
125128
encoding = '%s/%s' % (encoding, errors)
126129
info_add('sys.%s.encoding' % name, encoding)
127130

128-
# Were we compiled --with-pydebug or with #define Py_DEBUG?
131+
# Were we compiled --with-pydebug?
129132
Py_DEBUG = hasattr(sys, 'gettotalrefcount')
130133
if Py_DEBUG:
131134
text = 'Yes (sys.gettotalrefcount() present)'
132135
else:
133136
text = 'No (sys.gettotalrefcount() missing)'
134-
info_add('Py_DEBUG', text)
137+
info_add('build.Py_DEBUG', text)
138+
139+
# Were we compiled --with-trace-refs?
140+
Py_TRACE_REFS = hasattr(sys, 'getobjects')
141+
if Py_TRACE_REFS:
142+
text = 'Yes (sys.getobjects() present)'
143+
else:
144+
text = 'No (sys.getobjects() missing)'
145+
info_add('build.Py_REF_DEBUG', text)
135146

136147

137148
def collect_platform(info_add):
@@ -444,6 +455,11 @@ def collect_datetime(info_add):
444455

445456

446457
def collect_sysconfig(info_add):
458+
# On Windows, sysconfig is not reliable to get macros used
459+
# to build Python
460+
if MS_WINDOWS:
461+
return
462+
447463
import sysconfig
448464

449465
for name in (
@@ -477,6 +493,28 @@ def collect_sysconfig(info_add):
477493
value = normalize_text(value)
478494
info_add('sysconfig[%s]' % name, value)
479495

496+
PY_CFLAGS = sysconfig.get_config_var('PY_CFLAGS')
497+
NDEBUG = (PY_CFLAGS and '-DNDEBUG' in PY_CFLAGS)
498+
if NDEBUG:
499+
text = 'ignore assertions (macro defined)'
500+
else:
501+
text= 'build assertions (macro not defined)'
502+
info_add('build.NDEBUG',text)
503+
504+
for name in (
505+
'WITH_DOC_STRINGS',
506+
'WITH_DTRACE',
507+
'WITH_FREELISTS',
508+
'WITH_PYMALLOC',
509+
'WITH_VALGRIND',
510+
):
511+
value = sysconfig.get_config_var(name)
512+
if value:
513+
text = 'Yes'
514+
else:
515+
text = 'No'
516+
info_add(f'build.{name}', text)
517+
480518

481519
def collect_ssl(info_add):
482520
import os
@@ -588,7 +626,6 @@ def collect_testcapi(info_add):
588626
return
589627

590628
call_func(info_add, 'pymem.allocator', _testcapi, 'pymem_getallocatorsname')
591-
copy_attr(info_add, 'pymem.with_pymalloc', _testcapi, 'WITH_PYMALLOC')
592629

593630

594631
def collect_resource(info_add):
@@ -630,6 +667,13 @@ def collect_test_support(info_add):
630667
call_func(info_add, 'test_support._is_gui_available', support, '_is_gui_available')
631668
call_func(info_add, 'test_support.python_is_optimized', support, 'python_is_optimized')
632669

670+
info_add('test_support.check_sanitizer(address=True)',
671+
support.check_sanitizer(address=True))
672+
info_add('test_support.check_sanitizer(memory=True)',
673+
support.check_sanitizer(memory=True))
674+
info_add('test_support.check_sanitizer(ub=True)',
675+
support.check_sanitizer(ub=True))
676+
633677

634678
def collect_cc(info_add):
635679
import subprocess

0 commit comments

Comments
 (0)