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 587637 - propertyhelper does not allow negative float values
propertyhelper does not allow negative float values
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: gobject
Git master
Other All
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2009-07-02 20:34 UTC by Zac Luzader
Modified: 2009-11-22 16:24 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Zac Luzader 2009-07-02 20:34:14 UTC
The pygobject property helper erroneously disallows negative float or double values because of a mistake in the type checking.

Steps to reproduce:
>>> import gobject
>>> gobject.property(type=float,minimum=-1)
Traceback (most recent call last):
  • File "<stdin>", line 1 in <module>
  • File "c:\program files\python25\lib\site-packages\gtk-2.0\gobject\propertyhelper.py", line 122 in __init__
    self.type, self._get_minimum()))
TypeError: Minimum for type <GType gdouble (60)> cannot be lower than 0

Expected behavior:
Negative minimum values should be allowed for float and double.

The range checking for float values in gobject.propertyhelper.property._get_minimum is incorrect, the minimum float value is not G_MINFLOAT, it is -G_MAXFLOAT. G_MINFLOAT is zero. Likewise for G_DOUBLE which is the translated value for python float.

The workaround is, obviously, to use __gproperties__ instead of the property helper.
Comment 1 Paul Pogonyshev 2009-11-22 16:24:41 UTC
Thank you for the report.  Fixed in master.