After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 664864 - property wrapper does not pass on min/max values
property wrapper does not pass on min/max values
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: gobject
unspecified
Other Windows
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2011-11-26 12:28 UTC by Javier Martin
Modified: 2011-12-12 17:36 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch for master branch (662 bytes, patch)
2011-12-09 11:57 UTC, Javier Martin
none Details | Review
Bugfix and test case (2.40 KB, patch)
2011-12-10 11:58 UTC, Sebastian Pölsterl
committed Details | Review

Description Javier Martin 2011-11-26 12:28:20 UTC
This bug is present both in 2.28 and master (I first noticed it when writing a PyGTK app). The gobject.property helper class does not correctly pass along the min/max values it was created with to the _install_properties method in the GObjectMeta metaclass.

The problem lies in the get_pspec_args method (line 301 in both master and 2.28, I believe): for all types accepting min/max values, the method returns self._get_minimum() and self._get_maximum(). Instead, it should return self.minimum and self.maximum, which are set by __init__ either to the user-supplied values or the defaults provided by _get_minimum() and get_maximum().

I have tested the patch on my own installation and it seems to work: setting a value out of range no longer calls a custom setter, instead displaying a warning about the value being out-of-range, which is the expected behaviour, and what happens when you declare the property with __gproperties__ directly.

This is a single-line pure-Python code change, so I request that the change be applied both to the master and 2.x branches.
Comment 1 Javier Martin 2011-11-26 12:29:53 UTC
As an off-comment, some test should be added to test_properties.py to check that user-specified ranges are taken into consideration (currently the test only checks that the type bounds are respected).
Comment 2 Javier Martin 2011-12-09 11:57:25 UTC
Created attachment 203141 [details] [review]
Patch for master branch

The same patch applies to the corresponding file in the 2.x branch.
Comment 3 Sebastian Pölsterl 2011-12-10 11:58:29 UTC
Created attachment 203183 [details] [review]
Bugfix and test case

Thanks for your patch, I additionally added a test case.
Comment 4 Tomeu Vizoso 2011-12-12 16:02:50 UTC
Review of attachment 203183 [details] [review]:

Thanks a lot for adding the test!
Comment 5 Sebastian Pölsterl 2011-12-12 17:36:31 UTC
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.