[pygobject/pygobject-3-4] Fix maximum and minimum ranges of TYPE_(U)INT64 properties
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject/pygobject-3-4] Fix maximum and minimum ranges of TYPE_(U)INT64 properties
- Date: Mon, 26 Nov 2012 06:14:51 +0000 (UTC)
commit 9b98fa1a28806d6bd8678a12b1a3c0860d98ba5f
Author: Simonas Kazlauskas <simonas kazlauskas me>
Date: Fri Nov 23 19:57:56 2012 +0200
Fix maximum and minimum ranges of TYPE_(U)INT64 properties
In corner case where properties use values 2 ** 62 < Âx < 2 ** 63 for
TYPE_INT64 and 2 ** 63 < x < 2 ** 64 for TYPE_UINT64 they will raise
warnings even tough values are valid.
https://bugzilla.gnome.org/show_bug.cgi?id=688949
gi/_gobject/propertyhelper.py | 6 +++---
tests/test_properties.py | 11 ++++-------
2 files changed, 7 insertions(+), 10 deletions(-)
---
diff --git a/gi/_gobject/propertyhelper.py b/gi/_gobject/propertyhelper.py
index 82b06b0..c863192 100644
--- a/gi/_gobject/propertyhelper.py
+++ b/gi/_gobject/propertyhelper.py
@@ -93,14 +93,14 @@ class Property(object):
TYPE_DOUBLE: -G_MAXDOUBLE,
TYPE_INT: G_MININT,
TYPE_LONG: G_MINLONG,
- TYPE_INT64: -2 ** 62 - 1,
+ TYPE_INT64: -2 ** 63,
}
_max_value_lookup = {
TYPE_UINT: G_MAXUINT,
TYPE_ULONG: G_MAXULONG,
- TYPE_INT64: 2 ** 62 - 1,
- TYPE_UINT64: 2 ** 63 - 1,
+ TYPE_INT64: 2 ** 63 - 1,
+ TYPE_UINT64: 2 ** 64 - 1,
TYPE_FLOAT: G_MAXFLOAT,
TYPE_DOUBLE: G_MAXDOUBLE,
TYPE_INT: G_MAXINT,
diff --git a/tests/test_properties.py b/tests/test_properties.py
index 405375d..4091d41 100644
--- a/tests/test_properties.py
+++ b/tests/test_properties.py
@@ -16,7 +16,8 @@ from gi.repository.GObject import \
TYPE_STRING, TYPE_PYOBJECT
from gi.repository.GObject import \
- G_MININT, G_MAXINT, G_MAXUINT, G_MINLONG, G_MAXLONG, G_MAXULONG
+ G_MININT, G_MAXINT, G_MAXUINT, G_MINLONG, G_MAXLONG, G_MAXULONG, \
+ G_MAXUINT64, G_MAXINT64, G_MININT64
from gi.repository import Gio
from gi.repository import GLib
@@ -495,17 +496,13 @@ class TestProperty(unittest.TestCase):
self.assertEqual(o.prop_name, 10)
def test_range(self):
- maxint64 = 2 ** 62 - 1
- minint64 = -2 ** 62 - 1
- maxuint64 = 2 ** 63 - 1
-
types_ = [
(TYPE_INT, G_MININT, G_MAXINT),
(TYPE_UINT, 0, G_MAXUINT),
(TYPE_LONG, G_MINLONG, G_MAXLONG),
(TYPE_ULONG, 0, G_MAXULONG),
- (TYPE_INT64, minint64, maxint64),
- (TYPE_UINT64, 0, maxuint64),
+ (TYPE_INT64, G_MININT64, G_MAXINT64),
+ (TYPE_UINT64, 0, G_MAXUINT64),
]
for gtype, min, max in types_:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]