Skip to content

Commit 3b3da7b

Browse files
committed
gh-109276: Complete test.pythoninfo
* Enable collect_sysconfig() on Windows. * Add sysconfig 'abs_builddir' and 'srcdir' * Add sysconfig.is_python_build() * Add tempfile.gettempdir() * Remove compatiblity with Python 2.7 (print_function).
1 parent 9363769 commit 3b3da7b

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

Lib/test/pythoninfo.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
"""
22
Collect various information about Python to help debugging test failures.
33
"""
4-
from __future__ import print_function
54
import errno
65
import re
76
import sys
87
import traceback
9-
import unittest
108
import warnings
119

1210

13-
MS_WINDOWS = (sys.platform == 'win32')
14-
15-
1611
def normalize_text(text):
1712
if text is None:
1813
return None
@@ -493,13 +488,10 @@ def collect_datetime(info_add):
493488

494489

495490
def collect_sysconfig(info_add):
496-
# On Windows, sysconfig is not reliable to get macros used
497-
# to build Python
498-
if MS_WINDOWS:
499-
return
500-
501491
import sysconfig
502492

493+
info_add('sysconfig.is_python_build', sysconfig.is_python_build())
494+
503495
for name in (
504496
'ABIFLAGS',
505497
'ANDROID_API_LEVEL',
@@ -523,7 +515,9 @@ def collect_sysconfig(info_add):
523515
'Py_NOGIL',
524516
'SHELL',
525517
'SOABI',
518+
'abs_builddir',
526519
'prefix',
520+
'srcdir',
527521
):
528522
value = sysconfig.get_config_var(name)
529523
if name == 'ANDROID_API_LEVEL' and not value:
@@ -711,6 +705,7 @@ def collect_resource(info_add):
711705

712706

713707
def collect_test_socket(info_add):
708+
import unittest
714709
try:
715710
from test import test_socket
716711
except (ImportError, unittest.SkipTest):
@@ -896,6 +891,11 @@ def collect_fips(info_add):
896891
pass
897892

898893

894+
def collect_tempfile(info_add):
895+
import tempfile
896+
897+
info_add('tempfile.gettempdir', tempfile.gettempdir())
898+
899899
def collect_info(info):
900900
error = False
901901
info_add = info.add
@@ -930,6 +930,7 @@ def collect_info(info):
930930
collect_sysconfig,
931931
collect_testcapi,
932932
collect_testinternalcapi,
933+
collect_tempfile,
933934
collect_time,
934935
collect_tkinter,
935936
collect_windows,

0 commit comments

Comments
 (0)