mirror of https://github.com/python/cpython
gh-91325: Skip Stable ABI checks with Py_TRACE_REFS special build (GH-92046)
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
|
@ -9,6 +9,13 @@ from test.support.import_helper import import_module
|
||||||
from _testcapi import get_feature_macros
|
from _testcapi import get_feature_macros
|
||||||
|
|
||||||
feature_macros = 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')
|
ctypes_test = import_module('ctypes')
|
||||||
|
|
||||||
class TestStableABIAvailability(unittest.TestCase):
|
class TestStableABIAvailability(unittest.TestCase):
|
||||||
|
@ -441,7 +448,9 @@ SYMBOL_NAMES = (
|
||||||
"PyModule_AddObjectRef",
|
"PyModule_AddObjectRef",
|
||||||
"PyModule_AddStringConstant",
|
"PyModule_AddStringConstant",
|
||||||
"PyModule_AddType",
|
"PyModule_AddType",
|
||||||
|
"PyModule_Create2",
|
||||||
"PyModule_ExecDef",
|
"PyModule_ExecDef",
|
||||||
|
"PyModule_FromDefAndSpec2",
|
||||||
"PyModule_GetDef",
|
"PyModule_GetDef",
|
||||||
"PyModule_GetDict",
|
"PyModule_GetDict",
|
||||||
"PyModule_GetFilename",
|
"PyModule_GetFilename",
|
||||||
|
@ -911,6 +920,13 @@ SYMBOL_NAMES = (
|
||||||
"_Py_TrueStruct",
|
"_Py_TrueStruct",
|
||||||
"_Py_VaBuildValue_SizeT",
|
"_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']:
|
if feature_macros['MS_WINDOWS']:
|
||||||
SYMBOL_NAMES += (
|
SYMBOL_NAMES += (
|
||||||
'PyErr_SetExcFromWindowsErr',
|
'PyErr_SetExcFromWindowsErr',
|
||||||
|
@ -926,17 +942,6 @@ if feature_macros['MS_WINDOWS']:
|
||||||
'PyUnicode_DecodeMBCSStateful',
|
'PyUnicode_DecodeMBCSStateful',
|
||||||
'PyUnicode_EncodeCodePage',
|
'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']:
|
if feature_macros['PY_HAVE_THREAD_NATIVE_ID']:
|
||||||
SYMBOL_NAMES += (
|
SYMBOL_NAMES += (
|
||||||
'PyThread_get_thread_native_id',
|
'PyThread_get_thread_native_id',
|
||||||
|
@ -946,14 +951,23 @@ if feature_macros['Py_REF_DEBUG']:
|
||||||
'_Py_NegativeRefcount',
|
'_Py_NegativeRefcount',
|
||||||
'_Py_RefTotal',
|
'_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',
|
EXPECTED_FEATURE_MACROS = set(['HAVE_FORK',
|
||||||
'MS_WINDOWS',
|
'MS_WINDOWS',
|
||||||
'PY_HAVE_THREAD_NATIVE_ID',
|
'PY_HAVE_THREAD_NATIVE_ID',
|
||||||
'Py_REF_DEBUG',
|
'Py_REF_DEBUG',
|
||||||
|
'Py_TRACE_REFS',
|
||||||
'USE_STACKCHECK'])
|
'USE_STACKCHECK'])
|
||||||
WINDOWS_FEATURE_MACROS = {'HAVE_FORK': False,
|
WINDOWS_FEATURE_MACROS = {'HAVE_FORK': False,
|
||||||
'MS_WINDOWS': True,
|
'MS_WINDOWS': True,
|
||||||
'PY_HAVE_THREAD_NATIVE_ID': True,
|
'PY_HAVE_THREAD_NATIVE_ID': True,
|
||||||
'Py_REF_DEBUG': 'maybe',
|
'Py_REF_DEBUG': 'maybe',
|
||||||
|
'Py_TRACE_REFS': 'maybe',
|
||||||
'USE_STACKCHECK': 'maybe'}
|
'USE_STACKCHECK': 'maybe'}
|
||||||
|
|
|
@ -78,6 +78,10 @@
|
||||||
[feature_macro.Py_REF_DEBUG]
|
[feature_macro.Py_REF_DEBUG]
|
||||||
doc = 'when Python is compiled in debug mode (with Py_REF_DEBUG)'
|
doc = 'when Python is compiled in debug mode (with Py_REF_DEBUG)'
|
||||||
windows = 'maybe'
|
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:
|
# Mentioned in PEP 384:
|
||||||
|
|
|
@ -38,6 +38,15 @@ if (res) {
|
||||||
Py_DECREF(result); return NULL;
|
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
|
#ifdef USE_STACKCHECK
|
||||||
res = PyDict_SetItemString(result, "USE_STACKCHECK", Py_True);
|
res = PyDict_SetItemString(result, "USE_STACKCHECK", Py_True);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -278,6 +278,13 @@ def gen_ctypes_test(manifest, args, outfile):
|
||||||
from _testcapi import get_feature_macros
|
from _testcapi import get_feature_macros
|
||||||
|
|
||||||
feature_macros = 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')
|
ctypes_test = import_module('ctypes')
|
||||||
|
|
||||||
class TestStableABIAvailability(unittest.TestCase):
|
class TestStableABIAvailability(unittest.TestCase):
|
||||||
|
@ -308,16 +315,11 @@ def gen_ctypes_test(manifest, args, outfile):
|
||||||
{'function', 'data'},
|
{'function', 'data'},
|
||||||
include_abi_only=True,
|
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:
|
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:
|
if item.ifdef:
|
||||||
optional_items.setdefault(item.ifdef, []).append(item.name)
|
optional_items[item.ifdef].append(item.name)
|
||||||
else:
|
else:
|
||||||
write(f' "{item.name}",')
|
write(f' "{item.name}",')
|
||||||
write(")")
|
write(")")
|
||||||
|
@ -328,7 +330,6 @@ def gen_ctypes_test(manifest, args, outfile):
|
||||||
write(f" {name!r},")
|
write(f" {name!r},")
|
||||||
write(" )")
|
write(" )")
|
||||||
write("")
|
write("")
|
||||||
feature_macros = list(manifest.select({'feature_macro'}))
|
|
||||||
feature_names = sorted(m.name for m in feature_macros)
|
feature_names = sorted(m.name for m in feature_macros)
|
||||||
write(f"EXPECTED_FEATURE_MACROS = set({pprint.pformat(feature_names)})")
|
write(f"EXPECTED_FEATURE_MACROS = set({pprint.pformat(feature_names)})")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue