abi3info
abi3info is a Python library that provides programmatic access to information about CPython's stable ABI (Application Binary Interface), commonly referred to as 'abi3'. This includes details on types, functions, and macros available for creating compatible C extension modules. The current version is 2025.11.29, and it has a high release cadence, often driven by automated updates to its internal ABI data.
Common errors
-
ModuleNotFoundError: No module named 'abi3info'
cause The `abi3info` library is not installed in your current Python environment.fixInstall the library using pip: `pip install abi3info`. -
ValueError: Unknown version: '3.9'
cause You are requesting ABI information for a Python version that is either not supported by this `abi3info` release, or too old for the `abi3` concept itself (which started gaining stability around 3.2). The `requires_python` is >=3.10, but the data coverage might vary.fixCheck `abi3info.SUPPORTED_VERSIONS` to see which Python versions have ABI data available in your installed `abi3info` version. Ensure you are using a recent `abi3info` release for broader coverage. -
AttributeError: 'AbiInfo' object has no attribute 'non_existent_field'
cause You are trying to access a field or method on the `AbiInfo` object that does not exist or has been renamed.fixConsult the library's documentation or inspect the `AbiInfo` object's attributes (e.g., `dir(abi_info)`) to verify available fields. Specific ABI members are accessed via `abi_info.members['SymbolName']` which is a dictionary.
Warnings
- gotcha The ABI data provided by abi3info (e.g., `stable_abi.toml`) is frequently updated. This means the specific set of available members or their exact signatures for a given Python target version can change between different versions of the `abi3info` library.
- breaking The `abi3info` library requires Python 3.10 or newer. Attempting to install or run it on older Python versions will result in an installation error or runtime syntax errors.
- gotcha The `abi3` refers to a stable subset of the CPython API. It does not include all CPython internal functions. Attempting to query information for non-abi3 functions or non-existent members will result in KeyError or AttributeError.
Install
-
pip install abi3info
Imports
- get_abi_info
import abi3info abi_info = abi3info.get_abi_info('3.11') - get_current_abi_info
import abi3info current_abi = abi3info.get_current_abi_info()
Quickstart
import abi3info
# Get ABI information for a specific Python version (e.g., 3.11)
python_version = '3.11'
try:
abi = abi3info.get_abi_info(python_version)
print(f"ABI information for Python {python_version}:")
print(f" Version: {abi.version}")
print(f" First ABI version: {abi.first_abi_version}")
# Access a specific member, e.g., PyUnicode_FromWideChar
if 'PyUnicode_FromWideChar' in abi.members:
member = abi.members['PyUnicode_FromWideChar']
print(f" PyUnicode_FromWideChar signature: {member.signature}")
else:
print(f" PyUnicode_FromWideChar not found in ABI for {python_version}")
# Get ABI information for the current Python interpreter
current_abi = abi3info.get_current_abi_info()
print(f"\nABI information for current Python ({current_abi.version}):")
print(f" First ABI version: {current_abi.first_abi_version}")
except ValueError as e:
print(f"Error: {e}. Check available Python versions with abi3info.SUPPORTED_VERSIONS.")