[PyQt] QCryptographicHash.addData()
Florian Bruhin
me at the-compiler.org
Tue Feb 24 20:42:03 GMT 2015
* David Cortesi <davecortesi at gmail.com> [2015-02-24 12:32:38 -0800]:
> 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".
Yeah - this indeed doesn't make sense from the Python point of view.
> 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'.
I've brought this point up in October:
http://www.riverbankcomputing.com/pipermail/pyqt/2014-October/034903.html
This behaviour is now marked with a DeprecationWarning in PyQt 5.4 -
so probably with 5.5 or so QByteArray will only accept bytes objects,
and not strings - just like python3 handles bytes/strings too.
Florian
--
http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
I love long mails! | http://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150224/b608e061/attachment.sig>
More information about the PyQt
mailing list