https://github.com/vishwin created https://github.com/llvm/llvm-project/pull/188161
[PyObject members are not to be accessed directly](https://docs.python.org/3/c-api/structures.html#c.PyObject), but rather through macros, in this case `Py_REFCNT()`. In most, ie Global Interpreter Lock-enabled, CPython cases, `Py_REFCNT()` expands to accessing `ob_refcnt` anyway. However, in a free-threaded CPython, combined with disabling the limited API (since it requires the GIL for now), the direct member does not exist, causing the build to fail. The macro expands to the correct access method in the free-threaded configuration. >From 59b52d21715289ece09785df3cc4a4700c3ce2b2 Mon Sep 17 00:00:00 2001 From: Charlie Li <[email protected]> Date: Mon, 23 Mar 2026 22:10:58 -0400 Subject: [PATCH] [lldb] use the Py_REFCNT() macro instead of directly accessing member PyObject members are not to be accessed directly. --- lldb/bindings/python/python-wrapper.swig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/bindings/python/python-wrapper.swig b/lldb/bindings/python/python-wrapper.swig index bf59569920470..72f90f1b23c29 100644 --- a/lldb/bindings/python/python-wrapper.swig +++ b/lldb/bindings/python/python-wrapper.swig @@ -134,7 +134,7 @@ bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallTypeScript( #endif ) { pfunc_impl = (PyObject *)(*pyfunct_wrapper); - if (pfunc_impl->ob_refcnt == 1) { + if (Py_REFCNT(pfunc_impl) == 1) { Py_XDECREF(pfunc_impl); pfunc_impl = NULL; } _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
