PySide Bugzilla Closed for New Bugs

PySide is now a Qt Add-on and uses the Qt Project's JIRA Bug Tracker instead of this Bugzilla instance. This Bugzilla is left for reference purposes.

Bug 486 - Python special value None is not mapped correctly to C++ Null QVariant
: Python special value None is not mapped correctly to C++ Null QVariant
Status: CLOSED WONTFIX
Product: PySide
Classification: Unclassified
Component: QtCore
: HEAD
: All All
: P3 major
Assigned To: renato filho
:
:
:
  Show dependency treegraph
 
Reported: 2010-11-22 16:45 EET by Julien SCORDIA
Modified: 2011-01-06 16:25 EET (History)
10 users (show)

See Also:


Attachments
test using PyQt4 QVariant and its isNull() method (927 bytes, text/plain)
2010-11-22 16:45 EET, Julien SCORDIA
Details
equivalent code written with PySide. (916 bytes, text/plain)
2010-11-22 16:45 EET, Julien SCORDIA
Details
Code written in PyQt showing that this isn't a PySide bug. (978 bytes, application/octet-stream)
2010-12-20 14:30 EET, Hugo Parente Lima
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Julien SCORDIA 2010-11-22 16:45:01 EET
Created attachment 151 [details]
test using PyQt4 QVariant and its isNull() method

QVariant C++ type of Qt seems not to be mapped correctly to the special value
of Python, None.

In PyQt4, for example when reading a database, QVariant are returned, for
example by:
* QSqlQuery.value()
* data() method of QSqlTableModel

When these QVariants are Null (tested with .isNull() method of QVariant), then
we can conclude that the corresponding value in the database is a SQL NULL
special value.

A Null QVariant is created by, for example, QVariant( QString() ): Null
QVariant of type QVariant.String.

In PySide, there is no QVariant, so it is legitimate to think at "== None" for
a replacement to the .isNull() method, or to the way to construct a Null
QVariant in PyQt4.
But it seems that None is not correctly implemented to satisfy this
requirement.

See the two attached Python scripts:
* one in PyQt4, that gives the correct output:

firstname       lastname 
----------------------------
Danny   Young 
Christine       NULL 
Lars    Gordon 

* the other in PySide, that gives:

firstname       lastname 
----------------------------
Danny   Young 
Christine        
Lars    Gordon 

So, the NULL value in the database is not correctly handled by PySide.
See the code for more information.
Comment 1 Julien SCORDIA 2010-11-22 16:45:57 EET
Created attachment 152 [details]
equivalent code written with PySide.
Comment 2 Matti Airas 2010-11-22 17:18:45 EET
According to the description, this would appear to be a valid bug. Assigning P3
priority.
Comment 3 Hugo Parente Lima 2010-12-20 14:28:21 EET
PySide have the same behaviour of PyQt4, I ported your code to PyQt4 API2, run
and check that the values returned are the same.

The problem is that the API returns a QVariant holding a QString, so it's
transformed into a empty string even if the string is null.

If we change this we'll have yet another incompatibility with PyQt4 and we are
trying to avoid this.
Comment 4 Hugo Parente Lima 2010-12-20 14:30:02 EET
Created attachment 198 [details]
Code written in PyQt showing that this isn't a PySide bug.

arg.. the bugzilla web interface is just... non-intuitive at all... hehe
Comment 5 Matti Airas 2010-12-21 05:47:52 EET
(In reply to comment #3)
> PySide have the same behaviour of PyQt4, I ported your code to PyQt4 API2, run
> and check that the values returned are the same.

OK. Hugo, thanks for the explanation!
Comment 6 Julien SCORDIA 2010-12-23 11:21:35 EET
See the discussion here:

http://thread.gmane.org/gmane.comp.python.pyqt-pykde/21486

I will use PyQt API1 for the time being, waiting for another solution.

Thanks
Comment 7 renato filho 2011-01-06 16:25:21 EET
released on beta3