Skip to content

Commit 59e929b

Browse files
committed
test.pythoninfo logs Py_C_RECURSION_LIMIT
test.pythoninfo logs Py_C_RECURSION_LIMIT and other _testcapi and _testinternalcapi constants.
1 parent 21325ab commit 59e929b

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

Lib/test/pythoninfo.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,13 +665,35 @@ def collect_decimal(info_add):
665665

666666

667667
def collect_testcapi(info_add):
668+
try:
669+
import _testcapi
670+
except ImportError:
671+
return
672+
673+
for name in (
674+
'LONG_MAX', # always 32-bit on Windows, 64-bit on 64-bit Unix
675+
'PY_SSIZE_T_MAX',
676+
'Py_C_RECURSION_LIMIT',
677+
'SIZEOF_TIME_T', # 32-bit or 64-bit depending on the platform
678+
'SIZEOF_WCHAR_T', # 16-bit or 32-bit depending on the platform
679+
):
680+
copy_attr(info_add, f'_testcapi.{name}', _testcapi, name)
681+
682+
683+
def collect_testinternalcapi(info_add):
668684
try:
669685
import _testinternalcapi
670686
except ImportError:
671687
return
672688

673689
call_func(info_add, 'pymem.allocator', _testinternalcapi, 'pymem_getallocatorsname')
674690

691+
for name in (
692+
'SIZEOF_PYGC_HEAD',
693+
'SIZEOF_PYOBJECT',
694+
):
695+
copy_attr(info_add, f'_testinternalcapi.{name}', _testinternalcapi, name)
696+
675697

676698
def collect_resource(info_add):
677699
try:
@@ -907,6 +929,7 @@ def collect_info(info):
907929
collect_sys,
908930
collect_sysconfig,
909931
collect_testcapi,
932+
collect_testinternalcapi,
910933
collect_time,
911934
collect_tkinter,
912935
collect_windows,

Modules/_testcapimodule.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3922,6 +3922,7 @@ PyInit__testcapi(void)
39223922
PyModule_AddObject(m, "instancemethod", (PyObject *)&PyInstanceMethod_Type);
39233923

39243924
PyModule_AddIntConstant(m, "the_number_three", 3);
3925+
PyModule_AddIntMacro(m, Py_C_RECURSION_LIMIT);
39253926

39263927
TestError = PyErr_NewException("_testcapi.error", NULL, NULL);
39273928
Py_INCREF(TestError);

Modules/_testinternalcapi.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,6 +1552,11 @@ module_exec(PyObject *module)
15521552
return 1;
15531553
}
15541554

1555+
if (PyModule_Add(module, "SIZEOF_PYOBJECT",
1556+
PyLong_FromSsize_t(sizeof(PyObject))) < 0) {
1557+
return 1;
1558+
}
1559+
15551560
if (PyModule_Add(module, "SIZEOF_TIME_T",
15561561
PyLong_FromSsize_t(sizeof(time_t))) < 0) {
15571562
return 1;

0 commit comments

Comments
 (0)