[PyQt] 5.11: TypeErrors with QWebEngineCookieStore::setCookieFilter

Florian Bruhin me at the-compiler.org
Tue Jun 12 08:25:55 BST 2018


On Mon, Jun 11, 2018 at 05:51:07PM +0100, Phil Thompson wrote:
> On 11 Jun 2018, at 9:32 am, Florian Bruhin <me at the-compiler.org> wrote:
> > 
> > Hey,
> > 
> > I've tried implementing a cookie filter with the Qt 5.11 snapshot
> > (sip-4.19.9.dev1806101717, PyQt5_gpl-5.11.dev1806101728, Qt 5.11.1
> > branch, GCC 8.1.1 on Archlinux).
> > 
> > When trying in my real application with a:
> > 
> >  store = QWebEngineProfile.defaultProfile().cookieStore()
> >  store.setCookieFilter(lambda _info: True)
> > 
> > I get:
> > 
> >  TypeError: a 'bool' is expected not 'generator'
> > 
> > I've tried to write a minimal example (attached), but that seems to work
> > fine. However, when I add the commented "print", I get:
> > 
> >  TypeError: 'managedbuffer' object is not callable
> > 
> > Not sure if that's the same issue, or two different issues?
> 
> Should be fixed in tonight's snapshot.

Unfortunately it still seems to interact weirdly with other lambdas. In
my real code, I get:

  File ".../qutebrowser/browser/webengine/webenginetab.py", line 87, in <lambda>
    profile.clearVisitedLinks([url]))
TypeError: index 0 has type 'FilterRequest' but 'QUrl' is expected

The lambda looks like this and certainly always gets a QUrl:

  hist.url_cleared.connect(lambda url, profile=p: profile.clearVisitedLinks([url]))

I've also found another minimal example (attached), where I get this:

  TypeError: <lambda>() takes 0 positional arguments but 1 was given

Despite the two lambdas working fine on their own - it seems like the
QTimer lambda is invoked from the filter instead of the one I actually
passed.

Florian

-- 
https://www.qutebrowser.org | me at the-compiler.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
         I love long mails! | https://email.is-not-s.ms/
-------------- next part --------------
import sys

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

app = QApplication(sys.argv)

profile =  QWebEngineProfile.defaultProfile()
profile.cookieStore().setCookieFilter(lambda _info: True)
timer = QTimer()
timer.timeout.connect(lambda:
                      profile.clearVisitedLinks([QUrl('https://www.github.com/')]))

wv = QWebEngineView()
wv.load(QUrl("https://github.com/"))
wv.show()
app.exec_()
-------------- 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/20180612/42ecbfe9/attachment.sig>


More information about the PyQt mailing list