Package: src:storm
Version: 1.2-1
User: [email protected]
Usertags: python3.15
Tags: patch, ftbfs, forky, sid
Severity: important

Hi!

While rebuilding the python related packages against the Python 3.15rc2
version we found that storm fails to build from source [1].

The error is: warning: ‘PyWeakref_GET_OBJECT’ is deprecated
[-Wdeprecated-declarations]

And the fix is to migrate away from PyWeakref_GET_OBJECT.

I've applied this fix in the sandbox [2] to verify that it builds
successfully, please consider applying the patch to support the upcoming
3.15 version.

Setting the severity to important for now. Once Python 3.15 is released,
it will be added to python3-defaults and this bug will become release
critical.

Happy hacking,

[1]: https://debusine.debian.net/debian/r-python-python3.15/artifact/4587861/
[2]: https://debusine.debian.net/debian/r-python-python3.15/

--
"Can you imagine what I would do if I could do all I can?" -- Sun Tzu
Saludos /\/\ /\ >< `/
Description: Fix build with Python 3.15
 PyWeakref_GET_OBJECT was removed in Python 3.15 (it was deprecated since
 3.13). Use PyWeakref_GetRef, available since Python 3.13, instead.
Author: Maximiliano Curia <[email protected]>
Forwarded: no
Last-Update: 2026-09-10
Index: storm/storm/cextensions.c
===================================================================
--- storm.orig/storm/cextensions.c
+++ storm/storm/cextensions.c
@@ -23,6 +23,25 @@
 #include <Python.h>
 #include <structmember.h>
 
+/* PyWeakref_GET_OBJECT was removed in Python 3.15; PyWeakref_GetRef is
+ * available since Python 3.13. */
+#if PY_VERSION_HEX >= 0x030D0000
+#define Storm_WeakrefGetRef(ref, pobj) PyWeakref_GetRef((ref), (pobj))
+#else
+static int
+Storm_WeakrefGetRef(PyObject *ref, PyObject **pobj)
+{
+    PyObject *obj = PyWeakref_GET_OBJECT(ref);
+    if (obj == Py_None) {
+        *pobj = NULL;
+        return 0;
+    }
+    Py_INCREF(obj);
+    *pobj = obj;
+    return 1;
+}
+#endif
+
 
 #define CATCH(error_value, expression) \
         do { \
@@ -399,12 +418,15 @@ EventSystem_emit(EventSystemObject *self
     args = PyTuple_GetSlice(all_args, 1, PyTuple_GET_SIZE(all_args));
     if (args) {
         /* owner = self._owner_ref() */
-        PyObject *owner = PyWeakref_GET_OBJECT(self->_owner_ref);
+        PyObject *owner;
+        if (Storm_WeakrefGetRef(self->_owner_ref, &owner) < 0) {
+            Py_DECREF(args);
+            return NULL;
+        }
         /* if owner is not None: */
-        if (owner != Py_None) {
+        if (owner != NULL) {
             /* callbacks = self._hooks.get(name) */
             PyObject *callbacks = PyDict_GetItem(self->_hooks, name);
-            Py_INCREF(owner);
             /* if callbacks: */
             if (callbacks && PySet_GET_SIZE(callbacks) != 0) {
                 /* for callback, data in tuple(callbacks): */
@@ -1904,8 +1926,11 @@ error:
 static PyObject *
 ObjectInfo_get_obj(ObjectInfoObject *self, PyObject *args)
 {
-    PyObject *obj = PyWeakref_GET_OBJECT(self->_obj_ref);
-    Py_INCREF(obj);
+    PyObject *obj;
+    if (Storm_WeakrefGetRef(self->_obj_ref, &obj) < 0)
+        return NULL;
+    if (obj == NULL)
+        Py_RETURN_NONE;
     return obj;
 }
 

Reply via email to