[pygi] Use the limit constants from glib and interpret G_MAXUINT32 as PyLong_FromLongLong
- From: Tomeu Vizoso <tomeuv src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [pygi] Use the limit constants from glib and interpret G_MAXUINT32 as PyLong_FromLongLong
- Date: Mon, 30 Nov 2009 20:26:00 +0000 (UTC)
commit 542fdf6da4ad8f2d28d0d50152bd93cb4d8ee39a
Author: Tomeu Vizoso <tomeu sugarlabs org>
Date: Sat Nov 28 18:48:19 2009 +0000
Use the limit constants from glib and interpret G_MAXUINT32 as PyLong_FromLongLong
https://bugzilla.gnome.org/show_bug.cgi?id=602384
gi/pygi-argument.c | 14 +++++++-------
tests/test_gi.py | 18 +++++++++---------
2 files changed, 16 insertions(+), 16 deletions(-)
---
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index 48e0041..7740d0c 100644
--- a/gi/pygi-argument.c
+++ b/gi/pygi-argument.c
@@ -52,21 +52,21 @@ _pygi_g_type_tag_py_bounds (GITypeTag type_tag,
*lower = PyInt_FromLong(0);
break;
case GI_TYPE_TAG_INT32:
- *lower = PyInt_FromLong(-2147483648);
- *upper = PyInt_FromLong(2147483647);
+ *lower = PyInt_FromLong(G_MININT32);
+ *upper = PyInt_FromLong(G_MAXINT32);
break;
case GI_TYPE_TAG_UINT32:
/* Note: On 32-bit archs, this number doesn't fit in a long. */
- *upper = PyLong_FromLongLong(4294967295);
+ *upper = PyLong_FromLongLong(G_MAXUINT32);
*lower = PyInt_FromLong(0);
break;
case GI_TYPE_TAG_INT64:
/* Note: On 32-bit archs, these numbers don't fit in a long. */
- *lower = PyLong_FromLongLong(-9223372036854775808u);
- *upper = PyLong_FromLongLong(9223372036854775807);
+ *lower = PyLong_FromLongLong(G_MININT64);
+ *upper = PyLong_FromLongLong(G_MAXINT64);
break;
case GI_TYPE_TAG_UINT64:
- *upper = PyLong_FromUnsignedLongLong(18446744073709551615u);
+ *upper = PyLong_FromUnsignedLongLong(G_MAXUINT64);
*lower = PyInt_FromLong(0);
break;
case GI_TYPE_TAG_SHORT:
@@ -1479,7 +1479,7 @@ _pygi_argument_to_object (GArgument *arg,
value = arg->v_uint32;
}
- object = PyInt_FromLong(value);
+ object = PyLong_FromLongLong(value);
break;
}
case GI_TYPE_TAG_INT64:
diff --git a/tests/test_gi.py b/tests/test_gi.py
index ecbc0c8..d776c27 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -83,8 +83,8 @@ class TestBoolean(unittest.TestCase):
class TestInt8(unittest.TestCase):
- MAX = 2 ** 7 - 1
- MIN = - (2 ** 7)
+ MAX = gobject.G_MAXINT8
+ MIN = gobject.G_MININT8
def test_int8_return(self):
self.assertEquals(self.MAX, TestGI.int8_return_max())
@@ -125,7 +125,7 @@ class TestInt8(unittest.TestCase):
class TestUInt8(unittest.TestCase):
- MAX = 2 ** 8 - 1
+ MAX = gobject.G_MAXUINT8
def test_uint8_return(self):
self.assertEquals(self.MAX, TestGI.uint8_return())
@@ -155,8 +155,8 @@ class TestUInt8(unittest.TestCase):
class TestInt16(unittest.TestCase):
- MAX = 2 ** 15 - 1
- MIN = - (2 ** 15)
+ MAX = gobject.G_MAXINT16
+ MIN = gobject.G_MININT16
def test_int16_return(self):
self.assertEquals(self.MAX, TestGI.int16_return_max())
@@ -197,7 +197,7 @@ class TestInt16(unittest.TestCase):
class TestUInt16(unittest.TestCase):
- MAX = 2 ** 16 - 1
+ MAX = gobject.G_MAXUINT16
def test_uint16_return(self):
self.assertEquals(self.MAX, TestGI.uint16_return())
@@ -226,8 +226,8 @@ class TestUInt16(unittest.TestCase):
class TestInt32(unittest.TestCase):
- MAX = 2 ** 31 - 1
- MIN = - (2 ** 31)
+ MAX = gobject.G_MAXINT32
+ MIN = gobject.G_MININT32
def test_int32_return(self):
self.assertEquals(self.MAX, TestGI.int32_return_max())
@@ -268,7 +268,7 @@ class TestInt32(unittest.TestCase):
class TestUInt32(unittest.TestCase):
- MAX = 2 ** 32 - 1
+ MAX = gobject.G_MAXUINT32
def test_uint32_return(self):
self.assertEquals(self.MAX, TestGI.uint32_return())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]