[PyQt] QDataStream.writeUInt8 and writeInt8 unfriendly

Mickaël THOMAS mickael9 at gmail.com
Sat May 26 20:52:24 BST 2012


Hi,

I wanted to point out a very odd behavior (which is not that odd
actually, but still...)

The documentation says that QDataStream.writeUInt8 and
QDataStream.writeInt8 should be passed a str rather than an int, which
looks strange to me.

http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qdatastream.html#writeInt8

So to write 0x80, you need to write the following in Python2 :
datastream.writeInt8(chr(0x80))

And worse in Python3 :
datastream.writeInt8(bytes([0x80]))

I definitely think that quint8 should be converted to/from an int
rather than a char.

What's your thoughts on this?

Regards,
   Mickael


More information about the PyQt mailing list