diff --git a/Lib/test/test_cext/extension.c b/Lib/test/test_cext/extension.c index 65dd25d71f494b..b462a949bd9899 100644 --- a/Lib/test/test_cext/extension.c +++ b/Lib/test/test_cext/extension.c @@ -483,6 +483,18 @@ module_exec(PyObject *module) return -1; } #endif + +#ifdef Py_LIMITED_API + if (PyModule_AddIntMacro(module, Py_LIMITED_API) < 0) { + return -1; + } +#endif +#ifdef Py_TARGET_ABI3T + if (PyModule_AddIntMacro(module, Py_TARGET_ABI3T) < 0) { + return -1; + } +#endif + // Ignore "unused argument" warning when none of these macros is defined (void)module; return 0; diff --git a/Lib/test/test_cext/runtests.py b/Lib/test/test_cext/runtests.py index 6700b410b7d7a7..cb2725209de7dc 100644 --- a/Lib/test/test_cext/runtests.py +++ b/Lib/test/test_cext/runtests.py @@ -63,14 +63,19 @@ def main(): '__STRICT_ANSI__', '__cplusplus', '_MSVC_LANG', + 'Py_LIMITED_API', + 'Py_TARGET_ABI3T', ): try: value = getattr(testmod, name) except AttributeError: - pass - else: - print(f'{name}: {value}') - newline = True + continue + + if name in ('Py_LIMITED_API', 'Py_TARGET_ABI3T'): + value = f'0x{value:08x}' + + print(f'{name}: {value}') + newline = True if newline: print()