[PyQt] 5.11: TypeErrors with QWebEngineCookieStore::setCookieFilter

Phil Thompson phil at riverbankcomputing.com
Tue Jun 12 14:39:14 BST 2018


On 12 Jun 2018, at 10:28 am, Phil Thompson <phil at riverbankcomputing.com> wrote:
> 
> On 12 Jun 2018, at 8:25 am, Florian Bruhin <me at the-compiler.org> wrote:
>> 
>> 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.
> 
> I was hoping to avoid leaking a filter if you called setFilter() a second time, but it doesn't look like that's possible.

I think I've worked out how to do it. You will need tonight's SIP snapshot as well.

Phil


More information about the PyQt mailing list