[PyQt] PyQt 5.5 gives TypeError: invalid result type from model.roleNames()

Phil Thompson phil at riverbankcomputing.com
Fri Jul 10 17:40:53 BST 2015

On 08/07/2015 5:50 pm, Nenad Ognjanovic wrote:
> Hello,
> I've tried out the latest snapshots of PyQt and SIP with Qt 5.5.0, and
> I've been getting the following error that didn't happen in previous
> versions:
> TypeError: invalid result type from my_model.roleNames()
> I've extracted the minimal example that reproduces the problem, I've
> attached it to this email and as a gist here:
> https://gist.github.com/bgr/0fd25c6808260e0b5d0a
> Is this a bug or are we now expected to wrap the dict into some kind
> of JSValue wrapper or similar?

It's a bug in your code, see...


...you just need to use b"hello" rather than "hello".

However I have made changes in tonight's SIP and PyQt5 snapshots so that 
the error now reads...

TypeError: invalid result from DummyModel.roleNames(), a dict value has 
type 'str' but 'QByteArray' is expected

...which is hopefully more helpful.


More information about the PyQt mailing list