Hi, While rebuilding other packages, I found that my proposed patch breaks python-dbusmock [1].
My understanding is that adding the proper garbage collection has triggered an underlying bug: when a connection is getting unregistered, there might be more than one call to _object_path_unregister, which causes the second call to trigger an error. I have worked around this issue by adding a handler for the specific exception raised by DBusPyConnection_ExistingFromDBusConnection in this case inside the _object_path_unregister. With this change applied, python-dbusmock builds successfully. I have also updated my upstream PR with the same fix. Please consider reviewing the patch upstream and fixing the package to support the upcoming Python 3.15 migration. Thanks! [1]: https://debusine.debian.net/debian/r-python-python3.15/artifact/4473020/ --"Elegance is not a dispensable luxury but a quality that decides between success and failure."
-- Edsger W. Dijkstra Saludos /\/\ /\ >< `/
Index: dbus-python/dbus_bindings/conn-methods.c
===================================================================
--- dbus-python.orig/dbus_bindings/conn-methods.c
+++ dbus-python/dbus_bindings/conn-methods.c
@@ -39,7 +39,12 @@ _object_path_unregister(DBusConnection *
PyObject *callable;
conn_obj = (Connection *)DBusPyConnection_ExistingFromDBusConnection(conn);
- if (!conn_obj) goto out;
+ if (!conn_obj) {
+ if (PyErr_ExceptionMatches(PyExc_AssertionError)) {
+ PyErr_Clear();
+ }
+ goto out;
+ }
TRACE(conn_obj);
DBG("Connection at %p unregistering object path %s",
Index: dbus-python/test/test-client.py
===================================================================
--- dbus-python.orig/test/test-client.py
+++ dbus-python/test/test-client.py
@@ -110,6 +110,15 @@ class TestDBusBindings(unittest.TestCase
del bus
self.assertTrue(ref() is None)
+ def testWeakRefsWithExportedObject(self):
+ # regression test: destroying an object on a connection should not
+ # raise AssertionError if Connection weakref is cleared during dealloc
+ address = os.environ['DBUS_SESSION_BUS_ADDRESS']
+ conn = _dbus_bindings.Connection(address)
+ obj = dbus.service.Object(conn, '/test/path')
+ del obj
+ del conn
+
def testWeakRefsToBaseConnection(self):
# regression test, using Py_TPFLAGS_MANAGED_WEAKREF without
# Py_TPFLAGS_HAVE_GC produced invalid memory accesses, this test should
signature.asc
Description: PGP signature

