[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] QCryptographicHash.addData()
From:       Florian Bruhin <me () the-compiler ! org>
Date:       2015-02-24 20:42:03
Message-ID: 20150224204203.GG429 () tonks
[Download RAW message or body]

This is a MIME-formatted message.  If you see this text it means that your
E-mail software does not support MIME-formatted messages.

[Attachment #2 (multipart/signed)]
This is a MIME-formatted message.  If you see this text it means that your
E-mail software does not support MIME-formatted messages.


* David Cortesi <davecortesi@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@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/

["signature.asc" (application/pgp-signature)]
[Attachment #6 (text/plain)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic