heads-up: QtWebEngine 6.5 and "Argument list is empty" / pytest-qt aborts

Florian Bruhin me at the-compiler.org
Fri Mar 17 18:51:43 GMT 2023


Hey,

FYI, for anyone who has issues with abort()s on Qt 6.5 with QtWebEngine,
it looks like Qt now requires passing sys.argv[0] into it correctly.

The somewhat common pattern of doing:

    from PyQt6.QtWidgets import QApplication
    from PyQt6.QtWebEngineCore import QWebEngineProfile
    app = QApplication([])
    QWebEngineProfile()

will now lead to:

    Argument list is empty, the program name is not passed to
    QCoreApplication. base::CommandLine cannot be properly initialized.

And you should instead use one of:

    QApplication(sys.argv)
    QApplication([sys.argv[0]])
    QApplication(sys.argv[:1])

(the first option passes all arguments on to Qt, which might or might
not be desirable).

This currently also causes issues with pytest-qt, which also passes an
empty list by default:

https://github.com/pytest-dev/pytest-qt/issues/483

This can be worked around by doing:

    @pytest.fixture(scope="session")
    def qapp_args():
        return [sys.argv[0]]

in something like a conftest.py.

I'm busy giving a Python company training until the end of the month, so
I might not get around to fixing this and getting out a new release.
Maybe nicoddemus (the primary maintainer of the plugin) will, but if
not, expect your tests to break if you're using QtWebEngine 6.5...

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/20230317/5fd0e372/attachment.sig>


More information about the PyQt mailing list