[From nobody Sun Sep 27 18:21:07 2026
Received: (at submit) by bugs.debian.org; 16 Aug 2026 13:26:00 +0000
X-Spam-Checker-Version: SpamAssassin 4.0.1-bugs.debian.org_2005_01_02
 (2024-03-25) on buxtehude.debian.org
X-Spam-Level: 
X-Spam-Status: No, score=-123.4 required=4.0 tests=ALL_TRUSTED,BAYES_00,
 BODY_INCLUDES_PACKAGE,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,
 DKIM_VALID_AU,DKIM_VALID_EF,FOURLA,FROMDEVELOPER,HAS_PACKAGE,
 PGPSIGNATURE,SPF_HELO_NONE,SPF_PASS,USER_IN_DKIM_WELCOMELIST
 autolearn=ham autolearn_force=no
 version=4.0.1-bugs.debian.org_2005_01_02
X-Spam-Bayes: score:0.0000 Tokens: new, 127; hammy, 150; neutral, 257; spammy,
 0. spammytokens:
 hammytokens:0.000-+--Hx-spam-relays-external:sk:stravin,
 0.000-+--H*RT:sk:stravin, 0.000-+--Hx-spam-relays-external:311,
 0.000-+--H*RT:311, 0.000-+--H*RT:108
Return-path: &lt;maxy@debian.org&gt;
Received: from stravinsky.debian.org ([2001:41b8:202:deb::311:108]:38300)
 by buxtehude.debian.org with esmtps
 (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256)
 (Exim 4.96) (envelope-from &lt;maxy@debian.org&gt;) id 1wvasC-009v6g-01
 for submit@bugs.debian.org; Sun, 16 Aug 2026 13:26:00 +0000
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; 
 s=smtpauto.stravinsky;
 h=X-Debian-User:Content-Type:MIME-Version:Message-ID:
 Subject:Cc:To:From:Date:Reply-To:Content-Transfer-Encoding:Content-ID:
 Content-Description:In-Reply-To:References;
 bh=aXsFR+Gr8fdLon4j4oq/qEgRZIYPpMKGbkeZKGtrfLI=; b=WCgR7Zy4XRCIRb31+IFgviKwN0
 QYgkirMnr7jHjREitBvpvHAUCBZp7zDeMn+Omk7wxpTHtLR3RMHorJrU5HedwYgKdMvoAQuGDGV3y
 jh4MEK4bGI+s6F5JZlPsoBQave6h9h4zrnIxoTm/I0PK8zr8bzq1hABkYBrxf0vpd0OU/kjYN2fc8
 cGT9XNZc0Zdh8GQgoq8nR2dQBGl9rBJ8byU27wqc11ntZ/fSn5+njN2/tQEOi/rdx7JnRZUe3rF1F
 wQlmF1V319W5EQmSCH9CFPAhCx5C2CHwYInqA/2YN8wxoaEuZHgTL/1sCv/RF9xe1wsGAU6WlMDh0
 ltCwwSAA==;
Received: from authenticated-user by stravinsky.debian.org with esmtpsa
 (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256)
 (Exim 4.96) (envelope-from &lt;maxy@debian.org&gt;) id 1wvasA-007U61-1C;
 Sun, 16 Aug 2026 13:25:58 +0000
Date: Sun, 16 Aug 2026 15:25:57 +0200
From: Maximiliano Curia &lt;maxy@debian.org&gt;
To: submit@bugs.debian.org
Cc: debian-python@lists.debian.org
Subject: dbus-python: Unimportable module when building in Python 3.15
Message-ID: &lt;aoG6ZXOR7efUd4ub@hecuba.gnuservers.com.ar&gt;
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha512;
 protocol=&quot;application/pgp-signature&quot;; boundary=&quot;Vk+hX9KNI7Bpehxn&quot;
Content-Disposition: inline
X-Debian-User: maxy
Delivered-To: submit@bugs.debian.org

--Vk+hX9KNI7Bpehxn
Content-Type: multipart/mixed; boundary=&quot;FBwssfAowvtq1uSH&quot;
Content-Disposition: inline

--FBwssfAowvtq1uSH
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Package: src:dbus-python
Version: 1.4.0-1
User: debian-python@lists.debian.org
Usertags: python3.15

Hi!

While rebuilding packages against Python 3.15 we found that dbus-python
failed to build from source due to failing tests. All the tests were
saying something like:

test:         dbus-python:standalone
start time:   10:20:31
duration:     0.05s
result:       exit status 1
command:      DBUS_TEST_TMPDIR=3D/build/reproducible-path/dbus-python-1.4.0=
/build-3.15/test DBUS_TOP_SRCDIR=3D/build/reproducible-path/dbus-python-1.4=
=2E0 DBUS_PYTHON_VERSION=3D1.4.0 MALLOC_PERTURB_=3D171 UBSAN_OPTIONS=3Dhalt=
_on_error=3D1:abort_on_error=3D1:print_summary=3D1:print_stacktrace=3D1 PYT=
HONPATH=3D/build/reproducible-path/dbus-python-1.4.0:/build/reproducible-pa=
th/dbus-python-1.4.0/test:/build/reproducible-path/dbus-python-1.4.0/build-=
3.15:/build/reproducible-path/dbus-python-1.4.0/build-3.15/test MSAN_OPTION=
S=3Dhalt_on_error=3D1:abort_on_error=3D1:print_summary=3D1:print_stacktrace=
=3D1 ASAN_OPTIONS=3Dhalt_on_error=3D1:abort_on_error=3D1:print_summary=3D1 =
DBUS_TEST_UNINSTALLED=3D1 DBUS_FATAL_WARNINGS=3D1 MESON_TEST_ITERATION=3D1 =
DBUS_TOP_BUILDDIR=3D/build/reproducible-path/dbus-python-1.4.0/build-3.15 /=
usr/bin/dbus-run-session --config-file /build/reproducible-path/dbus-python=
-1.4.0/build-3.15/test/tmp-session-bus.conf -- /usr/bin/python3.15 /build/r=
eproducible-path/dbus-python-1.4.0/build-3.15/../test/test-standalone.py
----------------------------------- stderr --------------------------------=
---
Traceback (most recent call last):
   File &quot;/build/reproducible-path/dbus-python-1.4.0/build-3.15/../test/test=
-standalone.py&quot;, line 39, in &lt;module&gt;
     import _dbus_bindings
SystemError: type _dbus_bindings.Connection has the Py_TPFLAGS_MANAGED_WEAK=
REF flag but not Py_TPFLAGS_HAVE_GC flag

The problem seems to be caused by the fact that the Connection is a
GenericAlloc that's missing the PyGC_Head header header, this is now detect=
ed in
Python 3.15 (see: https://github.com/python/cpython/issues/134786).

The weakref was introduced by ebecd174 but the previous mechanism still
works, so I'm reverting ebecd174 and adding a regression test that
should fail in python 3.12 to 3.14.

Happy hacking,
--=20
&quot;Backtracking algorithms are nondeterministic, not in the sense of being=20
random, but in the sense of having free will.&quot;
-- Robert W. Floyd
Saludos /\/\ /\ &gt;&lt; `/

--FBwssfAowvtq1uSH
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename=no-managed-weakref-without-gc.patch
Content-Transfer-Encoding: quoted-printable

=46rom: Maximiliano Curia &lt;maxy@debian.org&gt;
Date: Sat, 16 Aug 2026 12:00:00 +0200
Subject: Don't use Py_TPFLAGS_MANAGED_WEAKREF on types without
 Py_TPFLAGS_HAVE_GC

Revert ebecd174 plus regression test.

Forwarded: no
Last-Update: 2026-08-16
---
Index: dbus-python/dbus_bindings/conn-internal.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- dbus-python.orig/dbus_bindings/conn-internal.h
+++ dbus-python/dbus_bindings/conn-internal.h
@@ -42,10 +42,8 @@ typedef struct {
      */
     PyObject *object_paths;
=20
-#if !DBUSPY_PY_VERSION_AT_LEAST(3, 12, 0, 0)
     /* Weak-references list to make Connections weakly referenceable */
     PyObject *weaklist;
-#endif
=20
     dbus_bool_t has_mainloop;
 } Connection;
Index: dbus-python/dbus_bindings/conn.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- dbus-python.orig/dbus_bindings/conn.c
+++ dbus-python/dbus_bindings/conn.c
@@ -238,9 +238,7 @@ DBusPyConnection_NewConsumingDBusConnect
     self-&gt;has_mainloop =3D (mainloop !=3D Py_None);
     self-&gt;conn =3D NULL;
     self-&gt;filters =3D PyList_New(0);
-#if !DBUSPY_PY_VERSION_AT_LEAST(3, 12, 0, 0)
     self-&gt;weaklist =3D NULL;
-#endif
     if (!self-&gt;filters) goto err;
     self-&gt;object_paths =3D PyDict_New();
     if (!self-&gt;object_paths) goto err;
@@ -394,10 +392,7 @@ static void Connection_tp_dealloc(Connec
     /* avoid clobbering any pending exception */
     PyErr_Fetch(&amp;et, &amp;ev, &amp;etb);
=20
-#if !DBUSPY_PY_VERSION_AT_LEAST(3, 12, 0, 0)
-    if (self-&gt;weaklist)
-#endif
-    {
+    if (self-&gt;weaklist) {
         PyObject_ClearWeakRefs((PyObject *)self);
     }
=20
@@ -460,19 +455,12 @@ PyTypeObject DBusPyConnection_Type =3D {
     0,                      /*tp_getattro*/
     0,                      /*tp_setattro*/
     0,                      /*tp_as_buffer*/
-#if DBUSPY_PY_VERSION_AT_LEAST(3, 12, 0, 0)
-    Py_TPFLAGS_MANAGED_WEAKREF |
-#endif
     Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
     Connection_tp_doc,      /*tp_doc*/
     0,                      /*tp_traverse*/
     0,                      /*tp_clear*/
     0,                      /*tp_richcompare*/
-#if DBUSPY_PY_VERSION_AT_LEAST(3, 12, 0, 0)
-    0,                      /*tp_weaklistoffset*/
-#else
     offsetof(Connection, weaklist),   /*tp_weaklistoffset*/
-#endif
     0,                      /*tp_iter*/
     0,                      /*tp_iternext*/
     DBusPyConnection_tp_methods,  /*tp_methods*/
Index: dbus-python/dbus_bindings/server.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- dbus-python.orig/dbus_bindings/server.c
+++ dbus-python/dbus_bindings/server.c
@@ -38,10 +38,8 @@ typedef struct {
     /* The Connection subtype for which this Server is a factory */
     PyObject *conn_class;
=20
-#if !DBUSPY_PY_VERSION_AT_LEAST(3, 12, 0, 0)
     /* Weak-references list to make server weakly referenceable */
     PyObject *weaklist;
-#endif
=20
     PyObject *mainloop;
 } Server;
@@ -425,9 +423,7 @@ Server_tp_new(PyTypeObject *cls, PyObjec
         return NULL;
     }
=20
-#if !DBUSPY_PY_VERSION_AT_LEAST(3, 12, 0, 0)
     ((Server *)self)-&gt;weaklist =3D NULL;
-#endif
     TRACE(self);
=20
     return self;
@@ -442,10 +438,7 @@ static void Server_tp_dealloc(Server *se
     /* avoid clobbering any pending exception */
     PyErr_Fetch(&amp;et, &amp;ev, &amp;etb);
=20
-#if !DBUSPY_PY_VERSION_AT_LEAST(3, 12, 0, 0)
-    if (self-&gt;weaklist)
-#endif
-    {
+    if (self-&gt;weaklist) {
         PyObject_ClearWeakRefs((PyObject *)self);
     }
=20
@@ -577,19 +570,12 @@ PyTypeObject DBusPyServer_Type =3D {
     0,                      /*tp_getattro*/
     0,                      /*tp_setattro*/
     0,                      /*tp_as_buffer*/
-#if DBUSPY_PY_VERSION_AT_LEAST(3, 12, 0, 0)
-    Py_TPFLAGS_MANAGED_WEAKREF |
-#endif
     Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
     Server_tp_doc,          /*tp_doc*/
     0,                      /*tp_traverse*/
     0,                      /*tp_clear*/
     0,                      /*tp_richcompare*/
-#if DBUSPY_PY_VERSION_AT_LEAST(3, 12, 0, 0)
-    0,                      /*tp_weaklistoffset*/
-#else
     offsetof(Server, weaklist),   /*tp_weaklistoffset*/
-#endif
     0,                      /*tp_iter*/
     0,                      /*tp_iternext*/
     DBusPyServer_tp_methods,/*tp_methods*/
Index: dbus-python/test/test-client.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- dbus-python.orig/test/test-client.py
+++ dbus-python/test/test-client.py
@@ -110,6 +110,22 @@ class TestDBusBindings(unittest.TestCase
         del bus
         self.assertTrue(ref() is None)
=20
+    def testWeakRefsToBaseConnection(self):
+        # dbus.SessionBus() is a Python subclass, which always has
+        # Py_TPFLAGS_HAVE_GC; the C types do not, so they need their own
+        # coverage. Marking a non-GC type Py_TPFLAGS_MANAGED_WEAKREF makes
+        # CPython look for the weakref slot in the PyGC_Head that was never
+        # allocated, which reads and writes off the front of the object.
+        address =3D os.environ['DBUS_SESSION_BUS_ADDRESS']
+        conn =3D _dbus_bindings.Connection(address)
+        try:
+            ref =3D weakref.ref(conn)
+            self.assertTrue(ref() is conn)
+        finally:
+            conn.close()
+        del conn
+        self.assertTrue(ref() is None)
+
     def testInterfaceKeyword(self):
         #test dbus_interface parameter
         print(self.remote_object.Echo(&quot;dbus_interface on Proxy test Passed=
&quot;,=20

--FBwssfAowvtq1uSH--

--Vk+hX9KNI7Bpehxn
Content-Type: application/pgp-signature; name=signature.asc

-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEE+JIdOnQEyG4RNSIVxxl2mbKbIyoFAmqBumUACgkQxxl2mbKb
Iyro3g/9EHffZENxLbCDoyX8YZvKJ+MA4Zyx/Td8w/+ztSVK78TnhUnsmU7694ba
B5qNYxWvMnV4j8lSPTvd1bbZNDnUtWsMSf8+M24cc9UXtMHxgQ1LCbdCta+dG2AT
oNt+o0wIIq1o+ODKvtWoFwuhip6m40YKiehK/816J/aTG2/n8C4aSpLCzV1RoGSo
3ujjaif2GfZaFLxNrjsScLp0hGA1h2Z4CabEXLJhumYn6Dv9GZ5w2Ge1TavnElMB
oy0xBz01RIK+XsMIXR/ACgjgITZNKMAD865ZdxS18AuBkPCqIrJhe0HX0HlnHXda
xjpvIrE3Pyw5cCdwbyWAvkCUy0u+lB7HQ7vvxZqVx1+0xft2aZqjTrrvyj2kIy2E
3TRVYYg5V/fAD1aNuZFNxuIVEkL7dZ7vh5GhAwOa6L9S0FH29/aIR5G3E9WinluK
fxcZAK2ahwJiTKCZB3W2crLu8Vgsx79abKI9oW+95ygZ53dDLC2bimjCEIJYIgSd
KMp+JMDEoHSZX/PMjKTYBNZGP02dy9ePANBvWHRSioEQX+DQU0VN0m6YqmukPrFr
AaOsIY+euPd1LxgWi9ZroCWtJUR8LulrjpzWVcpByzJl74WPoqvKwGh1eRFVx8+x
9g/tcVhdYsSi5tTST/3CQe/fteHvlJQ63lelhA/qVjA+VGBBY4M=
=2k7R
-----END PGP SIGNATURE-----

--Vk+hX9KNI7Bpehxn--
]