From 7f0f267630386c41fbf44a0f6115d2555ba82451 Mon Sep 17 00:00:00 2001 From: Julien Schueller Date: Thu, 13 Jun 2024 15:32:46 +0200 Subject: [PATCH] Python 3.13 deprecates PyWeakref_GET_OBJECT Closes #2863 --- Lib/python/pyrun.swg | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 8381f16d27f..f7305eff108 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1343,7 +1343,12 @@ SWIG_Python_GetSwigThis(PyObject *pyobj) (void)obj; # ifdef PyWeakref_CheckProxy if (PyWeakref_CheckProxy(pyobj)) { +#if PY_VERSION_HEX >= 0x030D0000 + PyWeakref_GetRef(pyobj, &pyobj); + Py_DECREF(pyobj); +#else pyobj = PyWeakref_GET_OBJECT(pyobj); +#endif if (pyobj && SwigPyObject_Check(pyobj)) return (SwigPyObject*) pyobj; }