summaryrefslogtreecommitdiff
path: root/gi
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:41:46 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:41:50 +0900
commit5a89ec21697bd9e08c9102b2a7b6c60b4652e66c (patch)
treee9e20b8b8764a0dd9f82ea1e574ec777b9fa67f6 /gi
parentb0a50e7198747efb1d09dca4a1778148beac9576 (diff)
downloadpygobject2-5a89ec21697bd9e08c9102b2a7b6c60b4652e66c.tar.gz
pygobject2-5a89ec21697bd9e08c9102b2a7b6c60b4652e66c.tar.bz2
pygobject2-5a89ec21697bd9e08c9102b2a7b6c60b4652e66c.zip
Imported Upstream version 3.13.1
Change-Id: If4647282414d88e0de6e0f879ba00a88843f7510 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'gi')
-rw-r--r--gi/importer.py9
-rw-r--r--gi/overrides/GIMarshallingTests.py4
-rw-r--r--gi/overrides/GLib.py6
-rw-r--r--gi/overrides/Gdk.py11
-rw-r--r--gi/overrides/Gio.py4
-rw-r--r--gi/overrides/Gtk.py12
-rw-r--r--gi/overrides/Pango.py3
-rw-r--r--gi/pygi-boxed.c6
-rw-r--r--gi/pygi-value.c23
-rw-r--r--gi/types.py2
10 files changed, 64 insertions, 16 deletions
diff --git a/gi/importer.py b/gi/importer.py
index aa95cf6..cea0f8b 100644
--- a/gi/importer.py
+++ b/gi/importer.py
@@ -21,7 +21,6 @@
# USA
from __future__ import absolute_import
-import logging
import sys
from ._gi import Repository
@@ -47,11 +46,11 @@ class DynamicImporter(object):
if path != self.path:
return
- if not repository.enumerate_versions(namespace):
- logging.error('Could not find any typelib for %s', namespace)
- return None
- else:
+ if repository.enumerate_versions(namespace):
return self
+ else:
+ raise ImportError('cannot import name %s, '
+ 'introspection typelib not found' % namespace)
def load_module(self, fullname):
if fullname in sys.modules:
diff --git a/gi/overrides/GIMarshallingTests.py b/gi/overrides/GIMarshallingTests.py
index b675adf..cc967b4 100644
--- a/gi/overrides/GIMarshallingTests.py
+++ b/gi/overrides/GIMarshallingTests.py
@@ -53,13 +53,13 @@ class OverridesObject(GIMarshallingTests.OverridesObject):
def __init__(self, long_):
GIMarshallingTests.OverridesObject.__init__(self)
# FIXME: doesn't work yet
- # self.long_ = long_
+ #self.long_ = long_
@classmethod
def new(cls, long_):
self = GIMarshallingTests.OverridesObject.new()
# FIXME: doesn't work yet
- # self.long_ = long_
+ #self.long_ = long_
return self
def method(self):
diff --git a/gi/overrides/GLib.py b/gi/overrides/GLib.py
index c541004..0e8f694 100644
--- a/gi/overrides/GLib.py
+++ b/gi/overrides/GLib.py
@@ -547,6 +547,9 @@ class Source(GLib.Source):
setattr(source, '__pygi_custom_source', True)
return source
+ def __init__(self, *args, **kwargs):
+ return super(Source, self).__init__()
+
def __del__(self):
if hasattr(self, '__pygi_custom_source'):
self.unref()
@@ -710,6 +713,9 @@ class IOChannel(GLib.IOChannel):
return GLib.IOChannel.win32_new_fd(hwnd)
raise TypeError('either a valid file descriptor, file name, or window handle must be supplied')
+ def __init__(self, *args, **kwargs):
+ return super(IOChannel, self).__init__()
+
def read(self, max_count=-1):
return io_channel_read(self, max_count)
diff --git a/gi/overrides/Gdk.py b/gi/overrides/Gdk.py
index 9d0ba7d..95030f8 100644
--- a/gi/overrides/Gdk.py
+++ b/gi/overrides/Gdk.py
@@ -202,6 +202,17 @@ class Event(Gdk.Event):
else:
raise AttributeError("'%s' object has no attribute '%s'" % (self.__class__.__name__, name))
+ def __setattr__(self, name, value):
+ real_event = getattr(self, '_UNION_MEMBERS').get(self.type)
+ if real_event:
+ setattr(getattr(self, real_event), name, value)
+ else:
+ Gdk.Event.__setattr__(self, name, value)
+
+ def __repr__(self):
+ base_repr = Gdk.Event.__repr__(self).strip("><")
+ return "<%s type=%r>" % (base_repr, self.type)
+
Event = override(Event)
__all__.append('Event')
diff --git a/gi/overrides/Gio.py b/gi/overrides/Gio.py
index e646821..5a5dd2f 100644
--- a/gi/overrides/Gio.py
+++ b/gi/overrides/Gio.py
@@ -82,14 +82,14 @@ class Settings(Gio.Settings):
def __getitem__(self, key):
# get_value() aborts the program on an unknown key
- if key not in self:
+ if not key in self:
raise KeyError('unknown key: %r' % (key,))
return self.get_value(key).unpack()
def __setitem__(self, key, value):
# set_value() aborts the program on an unknown key
- if key not in self:
+ if not key in self:
raise KeyError('unknown key: %r' % (key,))
# determine type string of this key
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index 8887da8..df55c2d 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -1115,17 +1115,20 @@ class TreePath(Gtk.TreePath):
except TypeError:
raise TypeError("could not parse subscript '%s' as a tree path" % path)
+ def __init__(self, *args, **kwargs):
+ super(TreePath, self).__init__()
+
def __str__(self):
return self.to_string()
def __lt__(self, other):
- return other is not None and self.compare(other) < 0
+ return not other is None and self.compare(other) < 0
def __le__(self, other):
- return other is not None and self.compare(other) <= 0
+ return not other is None and self.compare(other) <= 0
def __eq__(self, other):
- return other is not None and self.compare(other) == 0
+ return not other is None and self.compare(other) == 0
def __ne__(self, other):
return other is None or self.compare(other) != 0
@@ -1466,6 +1469,9 @@ class IconSet(Gtk.IconSet):
iconset = Gtk.IconSet.__new__(cls)
return iconset
+ def __init__(self, *args, **kwargs):
+ return super(IconSet, self).__init__()
+
IconSet = override(IconSet)
__all__.append('IconSet')
diff --git a/gi/overrides/Pango.py b/gi/overrides/Pango.py
index 0f7c484..365e47b 100644
--- a/gi/overrides/Pango.py
+++ b/gi/overrides/Pango.py
@@ -34,6 +34,9 @@ class FontDescription(Pango.FontDescription):
else:
return Pango.FontDescription.__new__(cls)
+ def __init__(self, *args, **kwargs):
+ return super(FontDescription, self).__init__()
+
FontDescription = override(FontDescription)
__all__.append('FontDescription')
diff --git a/gi/pygi-boxed.c b/gi/pygi-boxed.c
index 06324fd..c52858b 100644
--- a/gi/pygi-boxed.c
+++ b/gi/pygi-boxed.c
@@ -123,6 +123,12 @@ _boxed_init (PyObject *self,
PyObject *args,
PyObject *kwargs)
{
+ static char *kwlist[] = { NULL };
+
+ if (!PyArg_ParseTupleAndKeywords (args, kwargs, "", kwlist)) {
+ return -1;
+ }
+
/* Don't call PyGBoxed's init, which raises an exception. */
return 0;
}
diff --git a/gi/pygi-value.c b/gi/pygi-value.c
index f2cc27b..8235116 100644
--- a/gi/pygi-value.c
+++ b/gi/pygi-value.c
@@ -147,6 +147,11 @@ _pygi_argument_from_g_value(const GValue *value,
}
+/* Ignore g_value_array deprecations. Although they are deprecated,
+ * we still need to support the marshaling of them in PyGObject.
+ */
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
static int
pyg_value_array_from_pyobject(GValue *value,
PyObject *obj,
@@ -213,6 +218,8 @@ pyg_value_array_from_pyobject(GValue *value,
return 0;
}
+G_GNUC_END_IGNORE_DEPRECATIONS
+
static int
pyg_array_from_pyobject(GValue *value,
PyObject *obj)
@@ -489,6 +496,11 @@ pyg_value_from_pyobject_with_error(GValue *value, PyObject *obj)
break;
case G_TYPE_BOXED: {
PyGTypeMarshal *bm;
+ gboolean holds_value_array;
+
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+ holds_value_array = G_VALUE_HOLDS(value, G_TYPE_VALUE_ARRAY);
+ G_GNUC_END_IGNORE_DEPRECATIONS
if (obj == Py_None)
g_value_set_boxed(value, NULL);
@@ -510,9 +522,9 @@ pyg_value_from_pyobject_with_error(GValue *value, PyObject *obj)
g_value_take_boxed (value, n_value);
return pyg_value_from_pyobject_with_error (n_value, obj);
}
- else if (PySequence_Check(obj) &&
- G_VALUE_HOLDS(value, G_TYPE_VALUE_ARRAY))
+ else if (PySequence_Check(obj) && holds_value_array)
return pyg_value_array_from_pyobject(value, obj, NULL);
+
else if (PySequence_Check(obj) &&
G_VALUE_HOLDS(value, G_TYPE_ARRAY))
return pyg_array_from_pyobject(value, obj);
@@ -718,6 +730,11 @@ pyg_value_as_pyobject(const GValue *value, gboolean copy_boxed)
g_value_get_pointer(value));
case G_TYPE_BOXED: {
PyGTypeMarshal *bm;
+ gboolean holds_value_array;
+
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+ holds_value_array = G_VALUE_HOLDS(value, G_TYPE_VALUE_ARRAY);
+ G_GNUC_END_IGNORE_DEPRECATIONS
if (G_VALUE_HOLDS(value, PY_TYPE_OBJECT)) {
PyObject *ret = (PyObject *)g_value_dup_boxed(value);
@@ -729,7 +746,7 @@ pyg_value_as_pyobject(const GValue *value, gboolean copy_boxed)
} else if (G_VALUE_HOLDS(value, G_TYPE_VALUE)) {
GValue *n_value = g_value_get_boxed (value);
return pyg_value_as_pyobject(n_value, copy_boxed);
- } else if (G_VALUE_HOLDS(value, G_TYPE_VALUE_ARRAY)) {
+ } else if (holds_value_array) {
GValueArray *array = (GValueArray *) g_value_get_boxed(value);
PyObject *ret = PyList_New(array->n_values);
int i;
diff --git a/gi/types.py b/gi/types.py
index 6007e53..e6e3903 100644
--- a/gi/types.py
+++ b/gi/types.py
@@ -182,7 +182,7 @@ class _GObjectMetaBase(type):
cls._type_register(cls.__dict__)
def _type_register(cls, namespace):
- # don't register the class if already registered
+ ## don't register the class if already registered
if '__gtype__' in namespace:
return