Skip to content

Add a struct, slot & function for checking an extension's ABI #137210

@encukou

Description

@encukou

Feature or enhancement

See discussion: https://discuss.python.org/t/module-slot-for-checking-abi-compatibility/96443/

The checks we can do using C API are limited, but would still be useful, e.g. for the case of mixing up GIL-ful and free-threaded extensions/builds.

I propose adding:

  • PyABIInfo struct with:
    • abiinfo_major_version
    • abiinfo_minor_version
    • flags which can be set to:
      • PyABIInfo_DEFAULT_FLAGS
      • PyABIInfo_STABLE
      • PyABIInfo_INTERNAL
      • PyABIInfo_FREETHREADED
      • PyABIInfo_GIL
    • build_version
    • abi_version
  • int PyABIInfo_Check(PyABIInfo *info, const char *module_name)
  • PyABIInfo_VAR(NAME) macro that defines a suitable PyABIInfo variable
  • Py_mod_abi, a module slot that causes a PyABIInfo_Check call

C API WG vote pending: capi-workgroup/decisions#72

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions