On Thu, 18 Sep 2008 00:33:38 +0200, Giovanni Bajo <[EMAIL PROTECTED]>
wrote:
> On mar, 2008-09-16 at 21:54 +0100, Phil Thompson wrote:
>> On Wed, 10 Sep 2008 01:51:54 +0200, Giovanni Bajo <[EMAIL PROTECTED]>
>> wrote:
>> > Hello Phil,
>> >
>> > this looks weird to me (using sip 4.7.6, PyQt 4.4.2, Qt 4.4.0):
>> >
>> > =======================================
>> > $ python
>> > Python 2.5.2 (r252:60911, May 7 2008, 15:21:12)
>> > [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
>> > Type "help", "copyright", "credits" or "license" for more information.
>> >>>> from PyQt4.Qt import *
>> >>>> "a" == QString("a")
>> > True
>> >>>> u"a" == QString(u"a")
>> > True
>> >>>> a = u"\u30b5"
>> >>>> b = QString(a)
>> >>>> a
>> > u'\u30b5'
>> >>>> b
>> > PyQt4.QtCore.QString(u'\u30b5')
>> >>>> a == b
>> > False
>> > ========================================
>> >
>> > Why does the equality operator returns False?
>>
>> a is converting b to a string because QString supports the buffer
> protocol.
>> That conversion is done using the default codec which is normally ascii.
> If
>> QString didn't support the buffer protocol then I think Python would
> then
>> go on to try b == a, which would work.
>>
>> b == a works as expected because b is converting a to a QString first.
>
> I would say that this can't possibly be a feature. Before I begin with
> random suggestions on how to fix it, maybe you already have an idea?
Not without breaking things. Longer term the problem will go away because
QString will go away.
Phil
_______________________________________________
PyQt mailing list [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt