Bugreport: QDBusArgument does not work with PyQt6

Florian Bruhin me at the-compiler.org
Tue Jul 5 14:35:08 BST 2022


On Thu, Jun 30, 2022 at 07:55:42PM +0200, JakobDev wrote:
> This is strange. It crashes with message.setArguments() before it send
> anything, so there is nothing dbus-monitor could show. I have now
> attached a simpler code. The line
> arg.add(QDBusVariant(QByteArray(b"Hello"))) is the culprit. If I comment
> them out, it doesn't crash.- Also no crash under PyQt5 with this line.

FWIW I can reproduce with the attached example, on Archlinux, with both
Python 3.9 (and PyPI-installed PyQt 6.3.1) as well as the system-wide
Python 3.10 and PyQt.

Note however that I get the exact same error when I run your example
with PyQt5 (5.15.7 from PyPI) as well!

I've tried poking things with gdb a bit, but couldn't really find out
much. Looks like PyQt's qdbusargument_add indeed adds the QByteArray as
a PyQt_PyObject, from what I understand:

    #0  QMessageLogger::warning (this=this at entry=0x7fffffffc480,
        msg=msg at entry=0x7ffff78db2f8 "QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. Use qDBusRegisterMetaType to register it")
        at /usr/src/debug/qtbase-everywhere-src-6.3.1/src/corelib/global/qlogging.cpp:641
    #1  0x00007ffff7866184 in QDBusMarshaller::unregisteredTypeError (this=0x5555557a88d0, id=...)
        at /usr/src/debug/qtbase-everywhere-src-6.3.1/src/dbus/qdbusmarshaller.cpp:65
    #2  0x00007ffff7866c65 in QDBusMarshaller::appendVariantInternal(QVariant const&) [clone .isra.0] (this=0x5555557a88d0, Python Exception <class 'gdb.error'>: Cannot take address of method type.
    arg=)
        at /usr/src/debug/qtbase-everywhere-src-6.3.1/src/dbus/qdbusmarshaller.cpp:410
    #3  0x00007ffff7e77ad4 in qdbusargument_add (arg=0x5555557aa820, obj=<optimized out>, mtype=<optimized out>)
        at /usr/src/debug/PyQt6-6.3.1/sip/QtDBus/qdbusargument.sip:126
    #4  0x00007ffff7e77cc3 in meth_QDBusArgument_add (sipSelf=<optimized out>, sipArgs=<optimized out>, sipKwds=<optimized out>)
        at /usr/src/debug/PyQt6-6.3.1/sip/QtDBus/qdbusargument.sip:161

and:

    ...
    (gdb) up
    #3  0x00007ffff7e77ad4 in qdbusargument_add (arg=0x5555557aa820, obj=<optimized out>, mtype=<optimized out>)
        at /usr/src/debug/PyQt6-6.3.1/sip/QtDBus/qdbusargument.sip:126
    126	           arg->appendVariant(*qv);
    (gdb) p qv->typeName()
    $1 = 0x7ffff3e55ce0 <QtPrivate::QMetaTypeForType<PyQt_PyObject>::name> "PyQt_PyObject"

Florian

-- 
            me at the-compiler.org | https://www.qutebrowser.org 
       https://bruhin.software/ | https://github.com/sponsors/The-Compiler/
       GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
             I love long mails! | https://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20220705/f2c9f421/attachment.sig>


More information about the PyQt mailing list