On Sonntag, 10. Januar 2010, Phil Thompson wrote: > On Sun, 10 Jan 2010 14:05:36 +0100, detlev <[email protected]> > > wrote: > > On Sonntag, 10. Januar 2010, Phil Thompson wrote: > >> On Sat, 9 Jan 2010 18:33:32 +0100, detlev <[email protected]> > >> > >> wrote: > >> > Hi, > >> > > >> > really often I have this kind of code in my application when it comes > >> > to > >> > converting a QByteArray to s string under Python 3.1. > >> > > >> > s = bytes(QByteArray).decode() > >> > > >> > In Python 2 one could use > >> > > >> > s = unicode(QByteArray) > >> > > >> > to get the same result. Did I miss something or could QByteArray get a > >> > decode() method to make it similar to a Python3 bytes or bytearray > >> > type? > >> > >> The Python3 way to do it is... > >> > >> s = str(QByteArray, encoding='ascii') > >> > >> ...or whatever encoding is used. > >> > >> It would be possible to change things so that... > >> > >> s = str(QByteArray) > >> > >> ...automatically uses the default encoding. However that would then make > >> it > >> inconsistent with the behaviour of... > >> > >> s = str(bytes) > >> > >> ...and I'm not sure that that is a good idea. > >> > >> Phil > >> _______________________________________________ > >> PyQt mailing list [email protected] > >> http://www.riverbankcomputing.com/mailman/listinfo/pyqt > > > > Maybe QByteArray should be changed to a mapped type and bytearray should > > be > > > used (like the QString change). > > I've been thinking about that as well, but... > > - Qt uses QByteArray to represent binary data *and* C-style strings. It > might not be appropriate to convert the latter to bytearray. > > - are there places in Qt that a QByteArray is being used to hold a large > amount of data, and so the overhead of the conversion may be significant? > > - I would want the conversion to bytearray to be the default for Python v3 > (although changeable with sip.setapi()). Is it too late to be introducing > incompatible changes to the Python v3 support? > > Phil > _______________________________________________ > PyQt mailing list [email protected] > http://www.riverbankcomputing.com/mailman/listinfo/pyqt >
I'm nearly finished porting eric to Python3 (although there are probably a whole bunch of porting related bugs still to be discovered). Introducing an incompatible change would cause some extra work and would delay the first snapshot. However, if such a change is envisaged, it should be done now before a whole bunch of PyQt4 stuff has been ported. That means my opinion is "do it now or never". If it is done, it should be part of PyQt 4.7/sip 4.10. Regards, Detlev -- Detlev Offenbach [email protected] _______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
