[pygobject] Adjust to API break in GObject-Introspection
- From: Tomeu Vizoso <tomeuv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Adjust to API break in GObject-Introspection
- Date: Mon, 12 Jul 2010 08:35:50 +0000 (UTC)
commit 2efa18afbcc2fac1c90958535b2f80e6e730ee56
Author: =?UTF-8?q?Florian=20M=C3=BCllner?= <florian muellner gmail com>
Date: Mon Jul 12 10:31:42 2010 +0200
Adjust to API break in GObject-Introspection
As of commit 5cb925b20, many type_tags for standard C types have
been removed - namely machine-dependent integer types and derived
types (size_t, time_t).
Most removals are just synonyms of other types, so their removal
should not have too much impact, with the exception of time_t,
which was translated to a native datetime object before.
Also remove time_t tests (Tomeu Vizoso).
https://bugzilla.gnome.org/show_bug.cgi?id=624065
configure.ac | 2 +-
gi/importer.py | 7 ++-
gi/pygi-argument.c | 146 ----------------------------------------------------
gi/pygi-closure.c | 10 ----
gi/pygi-info.c | 37 -------------
tests/test_gi.py | 21 --------
6 files changed, 5 insertions(+), 218 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 1458681..784a6ff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -8,7 +8,7 @@ m4_define(pygobject_micro_version, 4)
m4_define(pygobject_version, pygobject_major_version.pygobject_minor_version.pygobject_micro_version)
dnl versions of packages we require ...
-m4_define(introspection_required_version, 0.6.14)
+m4_define(introspection_required_version, 0.9.1)
m4_define(pycairo_required_version, 1.0.2)
m4_define(glib_required_version, 2.22.4)
m4_define(gio_required_version, 2.22.4)
diff --git a/gi/importer.py b/gi/importer.py
index c79318e..6076692 100644
--- a/gi/importer.py
+++ b/gi/importer.py
@@ -21,8 +21,9 @@
# USA
from __future__ import absolute_import
-
+import logging
import sys
+
import gobject
from ._gi import Repository, RepositoryError
@@ -49,8 +50,8 @@ class DynamicImporter(object):
return
try:
repository.require(namespace)
- except RepositoryError:
- pass
+ except RepositoryError, e:
+ logging.exception(e)
else:
return self
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index 67d6656..9ace5d2 100644
--- a/gi/pygi-argument.c
+++ b/gi/pygi-argument.c
@@ -70,33 +70,6 @@ _pygi_g_type_tag_py_bounds (GITypeTag type_tag,
*upper = PyLong_FromUnsignedLongLong (G_MAXUINT64);
*lower = PyInt_FromLong (0);
break;
- case GI_TYPE_TAG_SHORT:
- *lower = PyInt_FromLong (G_MINSHORT);
- *upper = PyInt_FromLong (G_MAXSHORT);
- break;
- case GI_TYPE_TAG_USHORT:
- *upper = PyInt_FromLong (G_MAXUSHORT);
- *lower = PyInt_FromLong (0);
- break;
- case GI_TYPE_TAG_INT:
- *lower = PyInt_FromLong (G_MININT);
- *upper = PyInt_FromLong (G_MAXINT);
- break;
- case GI_TYPE_TAG_UINT:
- /* Note: On 32-bit archs, this number doesn't fit in a long. */
- *upper = PyLong_FromLongLong (G_MAXUINT);
- *lower = PyInt_FromLong (0);
- break;
- case GI_TYPE_TAG_LONG:
- case GI_TYPE_TAG_SSIZE:
- *lower = PyInt_FromLong (G_MINLONG);
- *upper = PyInt_FromLong (G_MAXLONG);
- break;
- case GI_TYPE_TAG_ULONG:
- case GI_TYPE_TAG_SIZE:
- *upper = PyLong_FromUnsignedLongLong (G_MAXULONG);
- *lower = PyInt_FromLong (0);
- break;
case GI_TYPE_TAG_FLOAT:
*upper = PyFloat_FromDouble (G_MAXFLOAT);
*lower = PyFloat_FromDouble (-G_MAXFLOAT);
@@ -216,14 +189,6 @@ _pygi_g_type_info_check_object (GITypeInfo *type_info,
case GI_TYPE_TAG_UINT32:
case GI_TYPE_TAG_INT64:
case GI_TYPE_TAG_UINT64:
- case GI_TYPE_TAG_SHORT:
- case GI_TYPE_TAG_USHORT:
- case GI_TYPE_TAG_INT:
- case GI_TYPE_TAG_UINT:
- case GI_TYPE_TAG_LONG:
- case GI_TYPE_TAG_ULONG:
- case GI_TYPE_TAG_SSIZE:
- case GI_TYPE_TAG_SIZE:
case GI_TYPE_TAG_FLOAT:
case GI_TYPE_TAG_DOUBLE:
{
@@ -284,13 +249,6 @@ check_number_release:
Py_XDECREF (upper);
break;
}
- case GI_TYPE_TAG_TIME_T:
- if (!PyDateTime_Check (object)) {
- PyErr_Format (PyExc_TypeError, "Must be datetime.datetime, not %s",
- object->ob_type->tp_name);
- retval = 0;
- }
- break;
case GI_TYPE_TAG_GTYPE:
{
gint is_instance;
@@ -661,11 +619,6 @@ _pygi_argument_from_object (PyObject *object,
case GI_TYPE_TAG_INT16:
case GI_TYPE_TAG_UINT16:
case GI_TYPE_TAG_INT32:
- case GI_TYPE_TAG_SHORT:
- case GI_TYPE_TAG_USHORT:
- case GI_TYPE_TAG_INT:
- case GI_TYPE_TAG_LONG:
- case GI_TYPE_TAG_SSIZE:
{
PyObject *int_;
@@ -682,9 +635,6 @@ _pygi_argument_from_object (PyObject *object,
}
case GI_TYPE_TAG_UINT32:
case GI_TYPE_TAG_UINT64:
- case GI_TYPE_TAG_UINT:
- case GI_TYPE_TAG_ULONG:
- case GI_TYPE_TAG_SIZE:
{
PyObject *number;
guint64 value;
@@ -756,35 +706,6 @@ _pygi_argument_from_object (PyObject *object,
break;
}
- case GI_TYPE_TAG_TIME_T:
- {
- PyDateTime_DateTime *py_datetime;
- struct tm datetime;
-
- py_datetime = (PyDateTime_DateTime *) object;
-
- if (py_datetime->hastzinfo) {
- if (PyErr_WarnEx (NULL, "tzinfo ignored; only local time is supported", 1) < 0) {
- break;
- }
- }
-
- datetime.tm_sec = PyDateTime_DATE_GET_SECOND (py_datetime);
- datetime.tm_min = PyDateTime_DATE_GET_MINUTE (py_datetime);
- datetime.tm_hour = PyDateTime_DATE_GET_HOUR (py_datetime);
- datetime.tm_mday = PyDateTime_GET_DAY (py_datetime);
- datetime.tm_mon = PyDateTime_GET_MONTH (py_datetime) - 1;
- datetime.tm_year = PyDateTime_GET_YEAR (py_datetime) - 1900;
- datetime.tm_isdst = -1;
-
- arg.v_long = mktime (&datetime);
- if (arg.v_long == -1) {
- PyErr_SetString (PyExc_RuntimeError, "datetime conversion failed");
- break;
- }
-
- break;
- }
case GI_TYPE_TAG_GTYPE:
{
arg.v_long = pyg_type_from_object (object);
@@ -1252,46 +1173,6 @@ _pygi_argument_to_object (GArgument *arg,
object = PyLong_FromUnsignedLongLong (arg->v_uint64);
break;
}
- case GI_TYPE_TAG_SHORT:
- {
- object = PyInt_FromLong (arg->v_short);
- break;
- }
- case GI_TYPE_TAG_USHORT:
- {
- object = PyInt_FromLong (arg->v_ushort);
- break;
- }
- case GI_TYPE_TAG_INT:
- {
- object = PyInt_FromLong (arg->v_int);
- break;
- }
- case GI_TYPE_TAG_UINT:
- {
- object = PyLong_FromLongLong (arg->v_uint);
- break;
- }
- case GI_TYPE_TAG_LONG:
- {
- object = PyInt_FromLong (arg->v_long);
- break;
- }
- case GI_TYPE_TAG_ULONG:
- {
- object = PyLong_FromUnsignedLongLong (arg->v_ulong);
- break;
- }
- case GI_TYPE_TAG_SSIZE:
- {
- object = PyInt_FromLong (arg->v_ssize);
- break;
- }
- case GI_TYPE_TAG_SIZE:
- {
- object = PyLong_FromUnsignedLongLong (arg->v_size);
- break;
- }
case GI_TYPE_TAG_FLOAT:
{
object = PyFloat_FromDouble (arg->v_float);
@@ -1302,24 +1183,6 @@ _pygi_argument_to_object (GArgument *arg,
object = PyFloat_FromDouble (arg->v_double);
break;
}
- case GI_TYPE_TAG_TIME_T:
- {
- time_t *time_;
- struct tm *datetime;
-
- time_ = (time_t *) &arg->v_long;
-
- datetime = localtime (time_);
- object = PyDateTime_FromDateAndTime (
- datetime->tm_year + 1900,
- datetime->tm_mon + 1,
- datetime->tm_mday,
- datetime->tm_hour,
- datetime->tm_min,
- datetime->tm_sec,
- 0);
- break;
- }
case GI_TYPE_TAG_GTYPE:
{
object = pyg_type_wrapper_new ( (GType) arg->v_long);
@@ -1692,17 +1555,8 @@ _pygi_argument_release (GArgument *arg,
case GI_TYPE_TAG_UINT32:
case GI_TYPE_TAG_INT64:
case GI_TYPE_TAG_UINT64:
- case GI_TYPE_TAG_SHORT:
- case GI_TYPE_TAG_USHORT:
- case GI_TYPE_TAG_INT:
- case GI_TYPE_TAG_UINT:
- case GI_TYPE_TAG_LONG:
- case GI_TYPE_TAG_ULONG:
- case GI_TYPE_TAG_SSIZE:
- case GI_TYPE_TAG_SIZE:
case GI_TYPE_TAG_FLOAT:
case GI_TYPE_TAG_DOUBLE:
- case GI_TYPE_TAG_TIME_T:
case GI_TYPE_TAG_GTYPE:
break;
case GI_TYPE_TAG_FILENAME:
diff --git a/gi/pygi-closure.c b/gi/pygi-closure.c
index a752ae2..eb9bb95 100644
--- a/gi/pygi-closure.c
+++ b/gi/pygi-closure.c
@@ -72,22 +72,12 @@ _pygi_closure_convert_ffi_arguments (GICallableInfo *callable_info, void **args)
case GI_TYPE_TAG_UINT32:
g_args[i].v_uint32 = * (guint32 *) args[i];
break;
- case GI_TYPE_TAG_LONG:
case GI_TYPE_TAG_INT64:
g_args[i].v_int64 = * (glong *) args[i];
break;
- case GI_TYPE_TAG_ULONG:
case GI_TYPE_TAG_UINT64:
g_args[i].v_uint64 = * (glong *) args[i];
break;
- case GI_TYPE_TAG_INT:
- case GI_TYPE_TAG_SSIZE:
- case GI_TYPE_TAG_SIZE:
- g_args[i].v_int32 = * (gint *) args[i];
- break;
- case GI_TYPE_TAG_UINT:
- g_args[i].v_uint32 = * (guint *) args[i];
- break;
case GI_TYPE_TAG_FLOAT:
g_args[i].v_float = * (gfloat *) args[i];
break;
diff --git a/gi/pygi-info.c b/gi/pygi-info.c
index 3d23271..7888ada 100644
--- a/gi/pygi-info.c
+++ b/gi/pygi-info.c
@@ -329,31 +329,12 @@ _pygi_g_type_tag_size (GITypeTag type_tag)
case GI_TYPE_TAG_UINT64:
size = sizeof (gint64);
break;
- case GI_TYPE_TAG_SHORT:
- case GI_TYPE_TAG_USHORT:
- size = sizeof (gshort);
- break;
- case GI_TYPE_TAG_INT:
- case GI_TYPE_TAG_UINT:
- size = sizeof (gint);
- break;
- case GI_TYPE_TAG_LONG:
- case GI_TYPE_TAG_ULONG:
- size = sizeof (glong);
- break;
- case GI_TYPE_TAG_SIZE:
- case GI_TYPE_TAG_SSIZE:
- size = sizeof (gsize);
- break;
case GI_TYPE_TAG_FLOAT:
size = sizeof (gfloat);
break;
case GI_TYPE_TAG_DOUBLE:
size = sizeof (gdouble);
break;
- case GI_TYPE_TAG_TIME_T:
- size = sizeof (time_t);
- break;
case GI_TYPE_TAG_GTYPE:
size = sizeof (GType);
break;
@@ -393,17 +374,8 @@ _pygi_g_type_info_size (GITypeInfo *type_info)
case GI_TYPE_TAG_UINT32:
case GI_TYPE_TAG_INT64:
case GI_TYPE_TAG_UINT64:
- case GI_TYPE_TAG_SHORT:
- case GI_TYPE_TAG_USHORT:
- case GI_TYPE_TAG_INT:
- case GI_TYPE_TAG_UINT:
- case GI_TYPE_TAG_LONG:
- case GI_TYPE_TAG_ULONG:
- case GI_TYPE_TAG_SIZE:
- case GI_TYPE_TAG_SSIZE:
case GI_TYPE_TAG_FLOAT:
case GI_TYPE_TAG_DOUBLE:
- case GI_TYPE_TAG_TIME_T:
case GI_TYPE_TAG_GTYPE:
if (g_type_info_is_pointer (type_info)) {
size = sizeof (gpointer);
@@ -780,19 +752,10 @@ pygi_g_struct_info_is_simple (GIStructInfo *struct_info)
case GI_TYPE_TAG_UINT16:
case GI_TYPE_TAG_INT32:
case GI_TYPE_TAG_UINT32:
- case GI_TYPE_TAG_SHORT:
- case GI_TYPE_TAG_USHORT:
- case GI_TYPE_TAG_INT:
- case GI_TYPE_TAG_UINT:
case GI_TYPE_TAG_INT64:
case GI_TYPE_TAG_UINT64:
- case GI_TYPE_TAG_LONG:
- case GI_TYPE_TAG_ULONG:
- case GI_TYPE_TAG_SSIZE:
- case GI_TYPE_TAG_SIZE:
case GI_TYPE_TAG_FLOAT:
case GI_TYPE_TAG_DOUBLE:
- case GI_TYPE_TAG_TIME_T:
if (g_type_info_is_pointer (field_type_info)) {
is_simple = FALSE;
}
diff --git a/tests/test_gi.py b/tests/test_gi.py
index 924d9e5..3444c9d 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -7,8 +7,6 @@ pygtk.require("2.0")
import unittest
from gi.repository import GObject
-from datetime import datetime
-
import sys
sys.path.insert(0, "../")
@@ -588,25 +586,6 @@ class TestDouble(unittest.TestCase):
self.assertAlmostEquals(self.MIN, GIMarshallingTests.double_inout(Number(self.MAX)))
-class TestTimeT(unittest.TestCase):
-
- DATETIME = datetime.fromtimestamp(1234567890)
-
- def test_time_t_return(self):
- self.assertEquals(self.DATETIME, GIMarshallingTests.time_t_return())
-
- def test_time_t_in(self):
- GIMarshallingTests.time_t_in(self.DATETIME)
-
- self.assertRaises(TypeError, GIMarshallingTests.time_t_in, "self.DATETIME")
-
- def test_time_t_out(self):
- self.assertEquals(self.DATETIME, GIMarshallingTests.time_t_out())
-
- def test_time_t_inout(self):
- self.assertEquals(datetime.fromtimestamp(0), GIMarshallingTests.time_t_inout(self.DATETIME))
-
-
class TestGType(unittest.TestCase):
def test_gtype_return(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]