Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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).
  • Loading branch information
vstinner committed Sep 12, 2023
commit 3b3da7bd99bf42b9ebd5412d511eb8c39195d446
21 changes: 11 additions & 10 deletions Lib/test/pythoninfo.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
"""
Collect various information about Python to help debugging test failures.
"""
from __future__ import print_function
import errno
import re
import sys
import traceback
import unittest
import warnings


MS_WINDOWS = (sys.platform == 'win32')


def normalize_text(text):
if text is None:
return None
Expand Down Expand Up @@ -493,13 +488,10 @@ def collect_datetime(info_add):


def collect_sysconfig(info_add):
# On Windows, sysconfig is not reliable to get macros used
# to build Python
if MS_WINDOWS:
return

import sysconfig

info_add('sysconfig.is_python_build', sysconfig.is_python_build())

for name in (
'ABIFLAGS',
'ANDROID_API_LEVEL',
Expand All @@ -523,7 +515,9 @@ def collect_sysconfig(info_add):
'Py_NOGIL',
'SHELL',
'SOABI',
'abs_builddir',
'prefix',
'srcdir',
):
value = sysconfig.get_config_var(name)
if name == 'ANDROID_API_LEVEL' and not value:
Expand Down Expand Up @@ -711,6 +705,7 @@ def collect_resource(info_add):


def collect_test_socket(info_add):
import unittest
try:
from test import test_socket
except (ImportError, unittest.SkipTest):
Expand Down Expand Up @@ -896,6 +891,11 @@ def collect_fips(info_add):
pass


def collect_tempfile(info_add):
import tempfile

info_add('tempfile.gettempdir', tempfile.gettempdir())

def collect_info(info):
error = False
info_add = info.add
Expand Down Expand Up @@ -930,6 +930,7 @@ def collect_info(info):
collect_sysconfig,
collect_testcapi,
collect_testinternalcapi,
collect_tempfile,
collect_time,
collect_tkinter,
collect_windows,
Expand Down