[PyQt] QCryptographicHash.addData()

David Cortesi davecortesi at gmail.com
Tue Feb 24 20:32:38 GMT 2015


Per the docs[1] QCryptographicHash is supposed to support a method
addData(const char * data, int len) but it seems not to.

from PyQt5.QtCore import QCryptographicHash
> blendr = QCryptographicHash(QCryptographicHash.Sha1)
> blendr.addData('str',3)
> Traceback (most recent call last):
>   File "<string>", line 1, in <fragment>
> builtins.TypeError: arguments did not match any overloaded call:
>   QCryptographicHash.addData(str): argument 1 has unexpected type 'str'
>   QCryptographicHash.addData(QByteArray): too many arguments
>   QCryptographicHash.addData(QIODevice): argument 1 has unexpected type
> 'str'
>

Perhaps this would not be very useful anyway; "const char *" probably means
"C bytestring" not "Python 3 str".

Also the one-arg method addData(const QByteArray data) seems to be encoding
a string arg to bytearray using the 'Latin-1' encoding,

blendr.addData('αβγ')
> Traceback (most recent call last):
>   File "<string>", line 1, in <fragment>
> builtins.UnicodeEncodeError: 'latin-1' codec can't encode characters in
> position 0-2: ordinal not in range(256)
>

This seems curious because in Python3 the default for str.encode() is
supposedly 'UTF-8'.

[1] http://doc.qt.io/qt-5/qcryptographichash.html#addData
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150224/147ac1ca/attachment.html>


More information about the PyQt mailing list