mirror of
https://github.com/python/cpython.git
synced 2024-11-21 12:59:38 +01:00
Skip Stable ABI checks with Py_TRACE_REFS special build This build is not compatible with Py_LIMITED_API nor with the stable ABI.
This commit is contained in:
parent
c87233fd3f
commit
15fe8cea17
36
Lib/test/test_stable_abi_ctypes.py
generated
36
Lib/test/test_stable_abi_ctypes.py
generated
@ -9,6 +9,13 @@ from test.support.import_helper import import_module
|
||||
from _testcapi import get_feature_macros
|
||||
|
||||
feature_macros = get_feature_macros()
|
||||
|
||||
# Stable ABI is incompatible with Py_TRACE_REFS builds due to PyObject
|
||||
# layout differences.
|
||||
# See https://github.com/python/cpython/issues/88299#issuecomment-1113366226
|
||||
if feature_macros['Py_TRACE_REFS']:
|
||||
raise unittest.SkipTest("incompatible with Py_TRACE_REFS.")
|
||||
|
||||
ctypes_test = import_module('ctypes')
|
||||
|
||||
class TestStableABIAvailability(unittest.TestCase):
|
||||
@ -441,7 +448,9 @@ SYMBOL_NAMES = (
|
||||
"PyModule_AddObjectRef",
|
||||
"PyModule_AddStringConstant",
|
||||
"PyModule_AddType",
|
||||
"PyModule_Create2",
|
||||
"PyModule_ExecDef",
|
||||
"PyModule_FromDefAndSpec2",
|
||||
"PyModule_GetDef",
|
||||
"PyModule_GetDict",
|
||||
"PyModule_GetFilename",
|
||||
@ -911,6 +920,13 @@ SYMBOL_NAMES = (
|
||||
"_Py_TrueStruct",
|
||||
"_Py_VaBuildValue_SizeT",
|
||||
)
|
||||
if feature_macros['HAVE_FORK']:
|
||||
SYMBOL_NAMES += (
|
||||
'PyOS_AfterFork',
|
||||
'PyOS_AfterFork_Child',
|
||||
'PyOS_AfterFork_Parent',
|
||||
'PyOS_BeforeFork',
|
||||
)
|
||||
if feature_macros['MS_WINDOWS']:
|
||||
SYMBOL_NAMES += (
|
||||
'PyErr_SetExcFromWindowsErr',
|
||||
@ -926,17 +942,6 @@ if feature_macros['MS_WINDOWS']:
|
||||
'PyUnicode_DecodeMBCSStateful',
|
||||
'PyUnicode_EncodeCodePage',
|
||||
)
|
||||
if feature_macros['HAVE_FORK']:
|
||||
SYMBOL_NAMES += (
|
||||
'PyOS_AfterFork',
|
||||
'PyOS_AfterFork_Child',
|
||||
'PyOS_AfterFork_Parent',
|
||||
'PyOS_BeforeFork',
|
||||
)
|
||||
if feature_macros['USE_STACKCHECK']:
|
||||
SYMBOL_NAMES += (
|
||||
'PyOS_CheckStack',
|
||||
)
|
||||
if feature_macros['PY_HAVE_THREAD_NATIVE_ID']:
|
||||
SYMBOL_NAMES += (
|
||||
'PyThread_get_thread_native_id',
|
||||
@ -946,14 +951,23 @@ if feature_macros['Py_REF_DEBUG']:
|
||||
'_Py_NegativeRefcount',
|
||||
'_Py_RefTotal',
|
||||
)
|
||||
if feature_macros['Py_TRACE_REFS']:
|
||||
SYMBOL_NAMES += (
|
||||
)
|
||||
if feature_macros['USE_STACKCHECK']:
|
||||
SYMBOL_NAMES += (
|
||||
'PyOS_CheckStack',
|
||||
)
|
||||
|
||||
EXPECTED_FEATURE_MACROS = set(['HAVE_FORK',
|
||||
'MS_WINDOWS',
|
||||
'PY_HAVE_THREAD_NATIVE_ID',
|
||||
'Py_REF_DEBUG',
|
||||
'Py_TRACE_REFS',
|
||||
'USE_STACKCHECK'])
|
||||
WINDOWS_FEATURE_MACROS = {'HAVE_FORK': False,
|
||||
'MS_WINDOWS': True,
|
||||
'PY_HAVE_THREAD_NATIVE_ID': True,
|
||||
'Py_REF_DEBUG': 'maybe',
|
||||
'Py_TRACE_REFS': 'maybe',
|
||||
'USE_STACKCHECK': 'maybe'}
|
||||
|
@ -78,6 +78,10 @@
|
||||
[feature_macro.Py_REF_DEBUG]
|
||||
doc = 'when Python is compiled in debug mode (with Py_REF_DEBUG)'
|
||||
windows = 'maybe'
|
||||
[feature_macro.Py_TRACE_REFS]
|
||||
# nb. This mode is not compatible with Stable ABI/Limited API.
|
||||
doc = 'when Python is compiled with Py_TRACE_REFS'
|
||||
windows = 'maybe'
|
||||
|
||||
|
||||
# Mentioned in PEP 384:
|
||||
|
@ -38,6 +38,15 @@ if (res) {
|
||||
Py_DECREF(result); return NULL;
|
||||
}
|
||||
|
||||
#ifdef Py_TRACE_REFS
|
||||
res = PyDict_SetItemString(result, "Py_TRACE_REFS", Py_True);
|
||||
#else
|
||||
res = PyDict_SetItemString(result, "Py_TRACE_REFS", Py_False);
|
||||
#endif
|
||||
if (res) {
|
||||
Py_DECREF(result); return NULL;
|
||||
}
|
||||
|
||||
#ifdef USE_STACKCHECK
|
||||
res = PyDict_SetItemString(result, "USE_STACKCHECK", Py_True);
|
||||
#else
|
||||
|
@ -278,6 +278,13 @@ def gen_ctypes_test(manifest, args, outfile):
|
||||
from _testcapi import get_feature_macros
|
||||
|
||||
feature_macros = get_feature_macros()
|
||||
|
||||
# Stable ABI is incompatible with Py_TRACE_REFS builds due to PyObject
|
||||
# layout differences.
|
||||
# See https://github.com/python/cpython/issues/88299#issuecomment-1113366226
|
||||
if feature_macros['Py_TRACE_REFS']:
|
||||
raise unittest.SkipTest("incompatible with Py_TRACE_REFS.")
|
||||
|
||||
ctypes_test = import_module('ctypes')
|
||||
|
||||
class TestStableABIAvailability(unittest.TestCase):
|
||||
@ -308,16 +315,11 @@ def gen_ctypes_test(manifest, args, outfile):
|
||||
{'function', 'data'},
|
||||
include_abi_only=True,
|
||||
)
|
||||
optional_items = {}
|
||||
feature_macros = list(manifest.select({'feature_macro'}))
|
||||
optional_items = {m.name: [] for m in feature_macros}
|
||||
for item in items:
|
||||
if item.name in (
|
||||
# Some symbols aren't exported on all platforms.
|
||||
# This is a bug: https://bugs.python.org/issue44133
|
||||
'PyModule_Create2', 'PyModule_FromDefAndSpec2',
|
||||
):
|
||||
continue
|
||||
if item.ifdef:
|
||||
optional_items.setdefault(item.ifdef, []).append(item.name)
|
||||
optional_items[item.ifdef].append(item.name)
|
||||
else:
|
||||
write(f' "{item.name}",')
|
||||
write(")")
|
||||
@ -328,7 +330,6 @@ def gen_ctypes_test(manifest, args, outfile):
|
||||
write(f" {name!r},")
|
||||
write(" )")
|
||||
write("")
|
||||
feature_macros = list(manifest.select({'feature_macro'}))
|
||||
feature_names = sorted(m.name for m in feature_macros)
|
||||
write(f"EXPECTED_FEATURE_MACROS = set({pprint.pformat(feature_names)})")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user