[pygobject] Remove pyg_type_is_a() and use GType.is_a() instead
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Remove pyg_type_is_a() and use GType.is_a() instead
- Date: Thu, 22 Mar 2018 07:04:40 +0000 (UTC)
commit f4f27e01cf199baf2f2a810a1b86a69388e43e2a
Author: Christoph Reiter <reiter christoph gmail com>
Date: Wed Mar 21 10:37:49 2018 +0100
Remove pyg_type_is_a() and use GType.is_a() instead
gi/_propertyhelper.py | 14 +++++++-------
gi/gimodule.c | 1 -
gi/gobjectmodule.c | 20 --------------------
gi/gobjectmodule.h | 1 -
4 files changed, 7 insertions(+), 29 deletions(-)
---
diff --git a/gi/_propertyhelper.py b/gi/_propertyhelper.py
index e81de2ed..3fd531b5 100644
--- a/gi/_propertyhelper.py
+++ b/gi/_propertyhelper.py
@@ -308,24 +308,24 @@ class Property(object):
elif ptype == TYPE_GTYPE:
if default is not None:
raise TypeError("GType types does not have default values")
- elif _gi.type_is_a(ptype, TYPE_ENUM):
+ elif ptype.is_a(TYPE_ENUM):
if default is None:
raise TypeError("enum properties needs a default value")
- elif not _gi.type_is_a(default, ptype):
+ elif not _gi.GType(default).is_a(ptype):
raise TypeError("enum value %s must be an instance of %r" %
(default, ptype))
- elif _gi.type_is_a(ptype, TYPE_FLAGS):
- if not _gi.type_is_a(default, ptype):
+ elif ptype.is_a(TYPE_FLAGS):
+ if not _gi.GType(default).is_a(ptype):
raise TypeError("flags value %s must be an instance of %r" %
(default, ptype))
- elif _gi.type_is_a(ptype, TYPE_STRV) and default is not None:
+ elif ptype.is_a(TYPE_STRV) and default is not None:
if not isinstance(default, list):
raise TypeError("Strv value %s must be a list" % repr(default))
for val in default:
if type(val) not in (str, bytes):
raise TypeError("Strv value %s must contain only strings" % str(default))
- elif _gi.type_is_a(ptype, TYPE_VARIANT) and default is not None:
- if not hasattr(default, '__gtype__') or not _gi.type_is_a(default, TYPE_VARIANT):
+ elif ptype.is_a(TYPE_VARIANT) and default is not None:
+ if not hasattr(default, '__gtype__') or not _gi.GType(default).is_a(TYPE_VARIANT):
raise TypeError("variant value %s must be an instance of %r" %
(default, ptype))
diff --git a/gi/gimodule.c b/gi/gimodule.c
index c551fffa..7a456b82 100644
--- a/gi/gimodule.c
+++ b/gi/gimodule.c
@@ -643,7 +643,6 @@ static PyMethodDef _gi_functions[] = {
"See the reference manual for a complete reference.\n" },
{ "type_name", pyg_type_name, METH_VARARGS },
{ "type_from_name", pyg_type_from_name, METH_VARARGS },
- { "type_is_a", pyg_type_is_a, METH_VARARGS },
{ "type_register", _wrap_pyg_type_register, METH_VARARGS },
{ "signal_new", pyg_signal_new, METH_VARARGS },
{ "list_properties",
diff --git a/gi/gobjectmodule.c b/gi/gobjectmodule.c
index 8f6f0d69..c872b33b 100644
--- a/gi/gobjectmodule.c
+++ b/gi/gobjectmodule.c
@@ -138,26 +138,6 @@ pyg_type_from_name (PyObject *self, PyObject *args)
return NULL;
}
-PyObject *
-pyg_type_is_a (PyObject *self, PyObject *args)
-{
- PyObject *gtype, *gparent;
- GType type, parent;
-#if 0
- if (PyErr_Warn(PyExc_DeprecationWarning,
- "gobject.type_is_a is deprecated; "
- "use GType.is_a instead"))
- return NULL;
-#endif
- if (!PyArg_ParseTuple(args, "OO:gobject.type_is_a", >ype, &gparent))
- return NULL;
- if ((type = pyg_type_from_object(gtype)) == 0)
- return NULL;
- if ((parent = pyg_type_from_object(gparent)) == 0)
- return NULL;
- return PyBool_FromLong(g_type_is_a(type, parent));
-}
-
static void
pyg_object_set_property (GObject *object, guint property_id,
const GValue *value, GParamSpec *pspec)
diff --git a/gi/gobjectmodule.h b/gi/gobjectmodule.h
index 13f2d942..042b6aaa 100644
--- a/gi/gobjectmodule.h
+++ b/gi/gobjectmodule.h
@@ -15,7 +15,6 @@ void pygobject_register_warnings (PyObject *d);
PyObject * pyg_type_name (PyObject *self, PyObject *args);
PyObject * pyg_type_from_name (PyObject *self, PyObject *args);
-PyObject * pyg_type_is_a (PyObject *self, PyObject *args);
PyObject * _wrap_pyg_type_register (PyObject *self, PyObject *args);
PyObject * pyg_signal_new (PyObject *self, PyObject *args);
PyObject * pyg_object_class_list_properties (PyObject *self, PyObject *args);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]