Unable to convert a C++ 'QWebEngineFindTextResult' instance to a Python object

Florian Bruhin <[email protected]> Thu, 7 May 2020 16:25:47 +0200
Newsgroups gmane.comp.python.pyqt-pykde
Message-ID <[email protected]>
Hey,

I got a report from someone using:

- Qt 5.14.1 (both QT_VERSION_STR and qVersion())
- PyQt 5.14.1
- sip 4.19.21

- QtWebEngine 5.14.1
- PyQtWebEngine 5.14.0 (note the .0)

- Python 3.6.10
- Gentoo Linux

Where emitting the QWebEnginePage.findTextFinished signal (added in Qt 5.14)
results in:

  TypeError: unable to convert a C++ 'QWebEngineFindTextResult' instance to a
  Python object

In a similar vein, trying to import it via:

  python3 -c "from PyQt5.QtWebEngineCore import QWebEngineFindTextResult"

results in:

  ImportError: cannot import name 'QWebEngineFindTextResult'

Test script:

--------------------------------------------------

from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QUrl, QTimer, pyqtSlot

app = QApplication([])

view = QWebEngineView()
view.load(QUrl('https://qutebrowser.org'))
view.show()

# @pyqtSlot('QWebEngineFindTextResult')
def slot(result):
    print(result.numberOfMatches())
    app.quit()

view.page().findTextFinished.connect(slot)
QTimer.singleShot(5000, lambda: view.findText("qutebrowser"))

app.exec_()

--------------------------------------------------

The crash happens after 5s, after findText got called. The pyqtSlot decorator
doesn't change anything.

I can't reproduce, and also don't know about any other people who have the same
issue...

Any idea what's going on there? Is their sip version too old or something?
Was there a bug in QtWebEngine 5.14.0 which was fixed in .1? I don't understand
what's happening, because both the findTextFinished signal and the
QWebEngineFindTextResult class is guarded by "%If (QtWebEngine_5_14_0 -)", so
surely both should be available?

Florian

-- 
[email protected] (Mail/XMPP) | 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/
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEE4E5WAAJAG47w528KkW6wyP1VoHIFAl60GmgACgkQkW6wyP1V
oHIxaA/+Jq5kqUgO4BR20Tmhbb/eQHVo0MOgQfvc74yTDHwE6kN6NlsJf8Y1KCxZ
ybo++WVeY0NrAbU0hdJ1PCq+7eXIF7/Hap3edvycxz0cMJbxfT82Lvnr4TXs6H2j
mSpxKOd8Zskl/UWaXK+ZKhhHzcFBOKiY3+06fYzH1gP/Mr5a/uK1YDRUOMivHjyR
usKd+U4uMmhOKmvsovTN6RGxKnl108iNO6+sc06EmKfZNP4JCtizF6RnjG/NwSR0
73o4W+51B88K8qKqWKNEMkAUZhYdhpxSrBW+byJlw9jv7YWBVWneoYYi33Zs8Uv2
2u9636LGKwv/dnUG1iDG0WeB7ivEWQXjBwoYZzlG3dZQhWUuQnnf/mQHPdb9g/WW
NMUJ2W44JosQ7v6J0csbNGziSFdqFN7h8KDx2xDZkuRAHl5RkpB9eAUTI+y4rtRg
jYqoJcEND70Q6fJ76rwIrNrM4q+zxdEt0+EyvUhgvbQ5qasOwhXAJySfk2zqUz3g
i/s/I7U5IXDyZQL2omKlc+6lCLAjK4vltRCFdjzY7GmrO5lZuBsNs9AK7cW7Io6s
y1s5JIraVKxGduPPIOVH/SdlZxrQmVoZ1ohCykcmoO93Y6856IiDOuKgc7j+cY+X
C35xiNflAxNfyifHNq+8HKfK1rv93B4cr/cOxgVtrCfy1HLBTOA=
=vQok
-----END PGP SIGNATURE-----