Skip to content

Commit 466aae5

Browse files
authored
bpo-33692: Update pythoninfo from master (GH-7298)
* bpo-33692: pythoninfo detect libedit on Python 3.6 (GH-7293) * bpo-33717: pythoninfo: add CC --version (GH-7290)
1 parent c6de46e commit 466aae5

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

Lib/test/pythoninfo.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,14 @@ def format_attr(attr, value):
275275
copy_attributes(info_add, readline, 'readline.%s', attributes,
276276
formatter=format_attr)
277277

278+
if not hasattr(readline, "_READLINE_LIBRARY_VERSION"):
279+
# _READLINE_LIBRARY_VERSION has been added to CPython 3.7
280+
doc = getattr(readline, '__doc__', '')
281+
if 'libedit readline' in doc:
282+
info_add('readline.library', 'libedit readline')
283+
elif 'GNU readline' in doc:
284+
info_add('readline.library', 'GNU readline')
285+
278286

279287
def collect_gdb(info_add):
280288
import subprocess
@@ -489,6 +497,34 @@ def collect_test_support(info_add):
489497
call_func(info_add, 'test_support.python_is_optimized', support, 'python_is_optimized')
490498

491499

500+
def collect_cc(info_add):
501+
import subprocess
502+
import sysconfig
503+
504+
CC = sysconfig.get_config_var('CC')
505+
if not CC:
506+
return
507+
508+
try:
509+
import shlex
510+
args = shlex.split(CC)
511+
except ImportError:
512+
args = CC.split()
513+
args.append('--version')
514+
proc = subprocess.Popen(args,
515+
stdout=subprocess.PIPE,
516+
stderr=subprocess.STDOUT,
517+
universal_newlines=True)
518+
stdout = proc.communicate()[0]
519+
if proc.returncode:
520+
# CC --version failed: ignore error
521+
return
522+
523+
text = stdout.splitlines()[0]
524+
text = normalize_text(text)
525+
info_add('CC.version', text)
526+
527+
492528
def collect_info(info):
493529
error = False
494530
info_add = info.add
@@ -515,6 +551,7 @@ def collect_info(info):
515551
collect_decimal,
516552
collect_testcapi,
517553
collect_resource,
554+
collect_cc,
518555

519556
# Collecting from tests should be last as they have side effects.
520557
collect_test_socket,

0 commit comments

Comments
 (0)