- Package:
- src:dbus-python
- Source:
- src:dbus-python
- Submitter:
- Maximiliano Curia
- Date:
- 2026-08-22 11:49:02 UTC
- Severity:
- normal
- Tags:
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=/build/reproducible-path/dbus-python-1.4.0/build-3.15/test DBUS_TOP_SRCDIR=/build/reproducible-path/dbus-python-1.4.0 DBUS_PYTHON_VERSION=1.4.0 MALLOC_PERTURB_=171 UBSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 PYTHONPATH=/build/reproducible-path/dbus-python-1.4.0:/build/reproducible-path/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_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 ASAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1 DBUS_TEST_UNINSTALLED=1 DBUS_FATAL_WARNINGS=1 MESON_TEST_ITERATION=1 DBUS_TOP_BUILDDIR=/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/reproducible-path/dbus-python-1.4.0/build-3.15/../test/test-standalone.py
----------------------------------- stderr -----------------------------------
Traceback (most recent call last):
File "/build/reproducible-path/dbus-python-1.4.0/build-3.15/../test/test-standalone.py", line 39, in <module>
import _dbus_bindings
SystemError: type _dbus_bindings.Connection has the Py_TPFLAGS_MANAGED_WEAKREF 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 detected 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,
Control: forwarded -1 https://gitlab.freedesktop.org/dbus/dbus-python/-/work_items/59
I'd prefer to address this upstream rather than as a Debian-specific
patch (see also: the forwarded report above).
Would this revert be considered (by Python upstream) to be a correct
solution, or a workaround, or what? Is there a porting guide available
that would clarify what the most appropriate change is?
ebecd174 was an attempt to follow what, at the time, I believed was
upstream best-practice. Perhaps I was wrong about that, or perhaps
best-practice has changed - but I'd prefer to know which is applicable.
Thanks,
smcv
¡Hola Simon!
El 2026-08-16 a las 15:14 +0100, Simon McVittie escribió:
I've been getting 504 Gateway Time-out errors from
gitlab.freedesktop.org, I could not clone the repository nor access
upsteam issue tracker.
Update, while checking the code the page finally could be loaded, it
would have been very useful to be able the access this issue prior
patching the code. :)
I'll try to send a version of this conversation upstream, if I manage to
create a user in the gitlab instance before another 504.
The issue with the way the weakref is handled in now detected as an
error, but it was trying to access an invalid memory before (see the
regression test, you can test it against 3.12, 3.13 or 3.14 and it
produces a segfault). The issue has to do with how the weak refs are
implemented in python, which basically uses the struct reserved for he
gc, which the connection and server objects don't have.
To have working weakrefs for connection and server, needs a bit of
tweaking of the parts.
So, the error actually says (a part of) how to solve it
'_dbus_bindings.Connection has the Py_TPFLAGS_MANAGED_WEAKREF flag but
not Py_TPFLAGS_HAVE_GC flag', that is in DBusPyConnection_Type (conn.c),
you'll need to add the flag Py_TPFLAGS_HAVE_GC:
#if DBUSPY_PY_VERSION_AT_LEAST(3, 12, 0, 0)
Py_TPFLAGS_MANAGED_WEAKREF | Py_TPFLAGS_HAVE_GC |
#endif
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
The same for DBusPyServer_Type.
But then you also need to write the corresponding traverse functions
(currently they are NULL) probably using Py_VISIT on the subelements
that can hold a python object, handle the GC on dealloc.
Well, I don't have as much context as you have about this project, I
think that you wanted a weakref to avoid an unclaimable reference
cycle, if that's the case, then the revert is going to bring that back.
So probably finishing the weakref patch would be a better approach (the
regression test I included in the patch should still be useful for
that).
Happy hacking,