From 845512e507bc9acc7c318fc4719bb6bd19078df2 Mon Sep 17 00:00:00 2001 From: Aditya Pillai Date: Mon, 10 Mar 2025 14:03:41 -0400 Subject: [PATCH 1/2] Use Py_REFCNT instead of ->ob_refcnt Py_REFCNT was stabilized in 3.9, uses this official API instead of the `ob_refcnt` field that doesn't exist in the free-threaded build of 3.13. --- src/converter/from_python.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/converter/from_python.cpp b/src/converter/from_python.cpp index 9678be1cb6..589d99effe 100644 --- a/src/converter/from_python.cpp +++ b/src/converter/from_python.cpp @@ -222,7 +222,7 @@ namespace , char const* ref_type) { handle<> holder(source); - if (source->ob_refcnt <= 1) + if (Py_REFCNT(source) <= 1) { handle<> msg( #if PY_VERSION_HEX >= 0x3000000 From 4f77b33a49019853d7eb6108811cf11ea6782769 Mon Sep 17 00:00:00 2001 From: Aditya Pillai Date: Mon, 10 Mar 2025 14:19:34 -0400 Subject: [PATCH 2/2] Conditionally use Py_REFCNT --- src/converter/from_python.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/converter/from_python.cpp b/src/converter/from_python.cpp index 589d99effe..f3989ba77f 100644 --- a/src/converter/from_python.cpp +++ b/src/converter/from_python.cpp @@ -222,7 +222,13 @@ namespace , char const* ref_type) { handle<> holder(source); - if (Py_REFCNT(source) <= 1) + if ( +#if PY_VERSION_HEX < 0x03090000 + source->ob_refcnt +#else + Py_REFCNT(source) +#endif + <= 1) { handle<> msg( #if PY_VERSION_HEX >= 0x3000000