]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-111506: Add _Py_OPAQUE_PYOBJECT to hide PyObject layout & related API (GH-136505)
authorPetr Viktorin <encukou@gmail.com>
Sat, 12 Jul 2025 07:55:12 +0000 (09:55 +0200)
committerGitHub <noreply@github.com>
Sat, 12 Jul 2025 07:55:12 +0000 (09:55 +0200)
commitc7d24b81c376b0cf0b34f861cb18c1b1e4eac27b
treec7955f1fb9d3172de046aa986cd7350e42c8941a
parentdb47f4d844acf2b6e52e44f7f3d5f7566b1e402c
gh-111506: Add _Py_OPAQUE_PYOBJECT to hide PyObject layout & related API (GH-136505)

Allow Py_LIMITED_API for (Py_GIL_DISABLED && _Py_OPAQUE_PYOBJECT)

API that's removed when _Py_OPAQUE_PYOBJECT is defined:

    - PyObject_HEAD
    - _PyObject_EXTRA_INIT
    - PyObject_HEAD_INIT
    - PyObject_VAR_HEAD
    - struct _object (i.e. PyObject) (opaque)
    - struct PyVarObject (opaque)
    - Py_SIZE
    - Py_SET_TYPE
    - Py_SET_SIZE
    - PyModuleDef_Base (opaque)
    - PyModuleDef_HEAD_INIT
    - PyModuleDef (opaque)
    - _Py_IsImmortal
    - _Py_IsStaticImmortal

Note that the `_Py_IsImmortal` removal (and a few other issues)
 means _Py_OPAQUE_PYOBJECT only works with limited
API 3.14+ now.

Co-authored-by: Victor Stinner <vstinner@python.org>
Include/Python.h
Include/moduleobject.h
Include/object.h
Include/refcount.h
Lib/test/test_cext/__init__.py
Lib/test/test_cext/create_moduledef.c [new file with mode: 0644]
Lib/test/test_cext/extension.c
Lib/test/test_cext/setup.py