summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
Diffstat (limited to 'Tools')
-rwxr-xr-xTools/scripts/stable_abi.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/Tools/scripts/stable_abi.py b/Tools/scripts/stable_abi.py
index 6cb310e..0179f3c 100755
--- a/Tools/scripts/stable_abi.py
+++ b/Tools/scripts/stable_abi.py
@@ -258,6 +258,44 @@ def gen_doc_annotations(manifest, args, outfile):
'added': item.added,
'ifdef_note': ifdef_note})
+@generator("ctypes_test", 'Lib/test/test_stable_abi_ctypes.py')
+def gen_ctypes_test(manifest, args, outfile):
+ """Generate/check the ctypes-based test for exported symbols"""
+ write = partial(print, file=outfile)
+ write(textwrap.dedent('''
+ # Generated by Tools/scripts/stable_abi.py
+
+ """Test that all symbols of the Stable ABI are accessible using ctypes
+ """
+
+ import unittest
+ from test.support.import_helper import import_module
+
+ ctypes_test = import_module('ctypes')
+
+ class TestStableABIAvailability(unittest.TestCase):
+ def test_available_symbols(self):
+ for symbol_name in SYMBOL_NAMES:
+ with self.subTest(symbol_name):
+ ctypes_test.pythonapi[symbol_name]
+
+ SYMBOL_NAMES = (
+ '''))
+ items = manifest.select(
+ {'function', 'data'},
+ include_abi_only=True,
+ ifdef=set())
+ 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
+ write(f' "{item.name}",')
+ write(")")
+
+
def generate_or_check(manifest, args, path, func):
"""Generate/check a file with a single generator