GNOME Bugzilla – Bug 664864
property wrapper does not pass on min/max values
Last modified: 2011-12-12 17:36:45 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.
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).
Created attachment 203141 [details] [review] Patch for master branch The same patch applies to the corresponding file in the 2.x branch.
Created attachment 203183 [details] [review] Bugfix and test case Thanks for your patch, I additionally added a test case.
Review of attachment 203183 [details] [review]: Thanks a lot for adding the test!
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.