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 612 - QColor.__reduce__ is not accurate
: QColor.__reduce__ is not accurate
Status: CLOSED FIXED
Product: PySide
Classification: Unclassified
Component: PySide
: HEAD
: All All
: P3 normal
Assigned To: renato filho
:
:
:
  Show dependency treegraph
 
Reported: 2011-01-13 15:07 EET by Farsmo
Modified: 2011-02-02 15:46 EET (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Farsmo 2011-01-13 15:07:23 EET
QColor.__reduce__ should use the fromRgbF, fromHslF... constructors to
accurately reconstruct QColor objects, because QColor has 16-bit precision so
float is required, and it stores data differently depending on whether it was
constructed from RGB or HSL.
Comment 1 Matti Airas 2011-01-14 07:45:34 EET
Thanks, prioritizing P3.
Comment 2 Hugo Parente Lima 2011-01-14 14:09:42 EET
The only way make __reduce__ working with QColor is create a custom constructor
for QColor with the signature:

QColor(QColor.Spec, *args)
Comment 3 Farsmo 2011-01-14 15:01:53 EET
I don't know if you're referring to a Shiboken or a Python limitation, but it's
perfectly possible for a __reduce__ method to specify a non-constructor:

| http://docs.python.org/library/pickle.html#object.__reduce__ :
|
| A callable object that will be called to create the initial version of the
| object. The next element of the tuple will provide arguments for this
callable,
| and later elements provide additional state information that will
subsequently
| be used to fully reconstruct the pickled data.
| 
| In the unpickling environment this object must be either a class, a callable
| registered as a “safe constructor” (see below), or it must have an attribute
| __safe_for_unpickling__ with a true value. Otherwise, an UnpicklingError will
| be raised in the unpickling environment. Note that as usual, the callable
| itself is pickled by name.
Comment 4 renato filho 2011-01-14 15:13:37 EET
Yes this is perfectly possible, we did this with other objects types.
We will fix this during the next sprint.

Thanks
Comment 5 renato filho 2011-01-25 15:40:18 EET
fixed on pyside commit:

commit c5fffa6f24afcf96cc65a885dd8e82b77617d045
Author: Renato Araujo Oliveira Filho <renato.filho@openbossa.org>
Date:   Mon Jan 24 18:18:45 2011 -0300
Comment 6 renato filho 2011-02-02 15:46:08 EET
released on beta 5