diff options
-rw-r--r-- | ChangeLog | 98 | ||||
-rw-r--r-- | NEWS | 10 | ||||
-rw-r--r-- | PKG-INFO | 4 | ||||
-rwxr-xr-x | configure | 24 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | gi/_gobject/propertyhelper.py | 12 | ||||
-rw-r--r-- | gi/_gobject/pygtype.c | 4 | ||||
-rw-r--r-- | gi/overrides/GObject.py | 106 | ||||
-rw-r--r-- | gi/pygi-closure.c | 3 | ||||
-rw-r--r-- | gi/pygi-marshal-from-py.c | 8 | ||||
-rw-r--r-- | gi/pygi-signal-closure.c | 2 | ||||
-rw-r--r-- | tests/test_overrides_gtk.py | 34 |
12 files changed, 241 insertions, 66 deletions
@@ -1,3 +1,101 @@ +commit ad8b7d1a89eb2d030a504d521f7589a4c1d835fb +Author: Martin Pitt <martinpitt@gnome.org> +Date: Mon Sep 2 14:38:41 2013 +0200 + + release 3.9.91 + + NEWS | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +commit 9df8eb79929025f12d51bc7f79b1d160156c2755 +Author: Simon Feltman <sfeltman@src.gnome.org> +Date: Mon Sep 2 04:19:35 2013 -0700 + + Fix GObject signal methods to work with new annotations + + Add conditional support for signal methods annotated as gpointer + or GObject.Object. This is needed to work with newer versions of + glib which changed annotations to GObject.Object (bug #685387). + + https://bugzilla.gnome.org/show_bug.cgi?id=707280 + + gi/overrides/GObject.py | 106 + ++++++++++++++++++++++++++++++------------------ + 1 file changed, 66 insertions(+), 40 deletions(-) + +commit 9b6b6c7ee6a621cba99f51857eadd622a1535118 +Author: Chun-wei Fan <fanchunwei@src.gnome.org> +Date: Thu Aug 15 14:41:40 2013 +0800 + + Fix build on C89 Compilers + + Avoid a variable declaration at the middle of the block + + https://bugzilla.gnome.org/show_bug.cgi?id=707264 + + gi/pygi-closure.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 19c1a2dfb91a83a6fb0ca76b9c95c42a49a3736e +Author: Simon Feltman <sfeltman@src.gnome.org> +Date: Sun Sep 1 20:44:26 2013 -0700 + + Change boxed type checking in marshaling to use __gtype__ attribute + + Replace usage of pyg_boxed_check(pyboxed) with g_type_is_a and + pyg_type_from_object. This has the effect of using the __gtype__ + attribute stashed on object class instead of the PyGBoxed + internally held gtype. This fixes type descrepencies for objects + marshaled into overridden signal class closures and passed back + to functions taking an alias their type. + + https://bugzilla.gnome.org/show_bug.cgi?id=707140 + + gi/pygi-marshal-from-py.c | 8 +++++++- + tests/test_overrides_gtk.py | 34 ++++++++++++++++++++++++++++++++++ + 2 files changed, 41 insertions(+), 1 deletion(-) + +commit dab0c09f1996e124ca98334e5aea0852904b44b5 +Author: Simon Feltman <sfeltman@src.gnome.org> +Date: Sun Sep 1 17:49:09 2013 -0700 + + Use G_IS_VALUE for checking return values in closure marshaling + + Replace return_value argument NULL checks in GClosureMarshal + implementations with G_IS_VALUE. This checks both NULL and + validity of the value (!= G_TYPE_INVALID). This is needed + because GLib can pass either NULL or an invalid value based + on whether or not G_ENABLE_DEBUG is set. + See: https://bugzilla.gnome.org/show_bug.cgi?id=707249 + + https://bugzilla.gnome.org/show_bug.cgi?id=707170 + + gi/_gobject/pygtype.c | 4 ++-- + gi/pygi-signal-closure.c | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +commit c7b75a8c250078ac8ea28752f087ed687bd20edd +Author: Yanko Kaneti <yaneti@declera.com> +Date: Wed Aug 21 08:53:07 2013 +0200 + + Fix PEP-8 errors in propertyhelper.py + + https://bugzilla.gnome.org/show_bug.cgi?id=706319 + + Signed-off-by: Martin Pitt <martinpitt@gnome.org> + + gi/_gobject/propertyhelper.py | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +commit 6fdd58404103596accb6ab04d4de33846d853c58 +Author: Martin Pitt <martinpitt@gnome.org> +Date: Mon Aug 19 17:13:30 2013 +0200 + + configure.ac: post-release bump to 3.9.91 + + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + commit 6fbe2580deda215896e9583b418b8bc1aceb2f96 Author: Martin Pitt <martinpitt@gnome.org> Date: Mon Aug 19 17:10:52 2013 +0200 @@ -1,3 +1,13 @@ +3.9.91 02-Sep-2013 + - Fix GObject signal methods to work with new annotations + (Simon Feltman) (#707280) + - Fix build on C89 Compilers (Chun-wei Fan) (#707264) + - Change boxed type checking in marshaling to use __gtype__ attribute + (Simon Feltman) (#707140) + - Use G_IS_VALUE for checking return values in closure marshaling + (Simon Feltman) (#707170) + - Fix PEP-8 errors in propertyhelper.py (Yanko Kaneti) (#706319) + 3.9.90 19-Aug-2013 - Create GLib.Pid in the same way on python 2 and 3 (Benjamin Berg) (#705451) @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: PyGObject -Version: 3.9.90 +Version: 3.9.91 Summary: Python bindings for GObject Home-page: http://www.pygtk.org/ Author: James Henstridge @@ -8,7 +8,7 @@ Author-email: james@daa.com.au Maintainer: Johan Dahlin Maintainer-email: johan@gnome.org License: GNU LGPL -Download-url: ftp://ftp.gnome.org/pub/GNOME/sources/pygobject/3.9/pygobject-3.9.90.tar.gz +Download-url: ftp://ftp.gnome.org/pub/GNOME/sources/pygobject/3.9/pygobject-3.9.91.tar.gz Description: Python bindings for GLib and GObject Platform: POSIX, Windows Classifier: Development Status :: 5 - Production/Stable @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for pygobject 3.9.90. +# Generated by GNU Autoconf 2.69 for pygobject 3.9.91. # # Report bugs to <http://bugzilla.gnome.org/enter_bug.cgi?product=pygobject>. # @@ -591,8 +591,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='pygobject' PACKAGE_TARNAME='pygobject' -PACKAGE_VERSION='3.9.90' -PACKAGE_STRING='pygobject 3.9.90' +PACKAGE_VERSION='3.9.91' +PACKAGE_STRING='pygobject 3.9.91' PACKAGE_BUGREPORT='http://bugzilla.gnome.org/enter_bug.cgi?product=pygobject' PACKAGE_URL='https://live.gnome.org/PyGObject/' @@ -1395,7 +1395,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures pygobject 3.9.90 to adapt to many kinds of systems. +\`configure' configures pygobject 3.9.91 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1465,7 +1465,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of pygobject 3.9.90:";; + short | recursive ) echo "Configuration of pygobject 3.9.91:";; esac cat <<\_ACEOF @@ -1602,7 +1602,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -pygobject configure 3.9.90 +pygobject configure 3.9.91 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1880,7 +1880,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by pygobject $as_me 3.9.90, which was +It was created by pygobject $as_me 3.9.91, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2244,9 +2244,9 @@ $as_echo "#define PYGOBJECT_MINOR_VERSION 9" >>confdefs.h PYGOBJECT_MINOR_VERSION=9 -$as_echo "#define PYGOBJECT_MICRO_VERSION 90" >>confdefs.h +$as_echo "#define PYGOBJECT_MICRO_VERSION 91" >>confdefs.h -PYGOBJECT_MICRO_VERSION=90 +PYGOBJECT_MICRO_VERSION=91 ac_config_headers="$ac_config_headers config.h" @@ -2766,7 +2766,7 @@ fi # Define the identity of the package. PACKAGE='pygobject' - VERSION='3.9.90' + VERSION='3.9.91' cat >>confdefs.h <<_ACEOF @@ -15332,7 +15332,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by pygobject $as_me 3.9.90, which was +This file was extended by pygobject $as_me 3.9.91, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -15399,7 +15399,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -pygobject config.status 3.9.90 +pygobject config.status 3.9.91 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 57a4de4..f405d4b 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,7 @@ m4_define(python3_min_ver, 3.1) dnl the pygobject version number m4_define(pygobject_major_version, 3) m4_define(pygobject_minor_version, 9) -m4_define(pygobject_micro_version, 90) +m4_define(pygobject_micro_version, 91) m4_define(pygobject_version, pygobject_major_version.pygobject_minor_version.pygobject_micro_version) dnl versions of packages we require ... diff --git a/gi/_gobject/propertyhelper.py b/gi/_gobject/propertyhelper.py index 162d30a..c9400df 100644 --- a/gi/_gobject/propertyhelper.py +++ b/gi/_gobject/propertyhelper.py @@ -185,16 +185,16 @@ class Property(object): if minimum is not None: if minimum < self._get_minimum(): raise TypeError( - "Minimum for type %s cannot be lower than %d" % ( - self.type, self._get_minimum())) + "Minimum for type %s cannot be lower than %d" % + (self.type, self._get_minimum())) else: minimum = self._get_minimum() self.minimum = minimum if maximum is not None: if maximum > self._get_maximum(): raise TypeError( - "Maximum for type %s cannot be higher than %d" % ( - self.type, self._get_maximum())) + "Maximum for type %s cannot be higher than %d" % + (self.type, self._get_maximum())) else: maximum = self._get_maximum() self.maximum = maximum @@ -393,8 +393,8 @@ def install_properties(cls): raise TypeError( "GObject subclass %r defines do_get/set_property" " and it also uses a property with a custom setter" - " or getter. This is not allowed" % ( - cls.__name__,)) + " or getter. This is not allowed" % + (cls.__name__,)) def obj_get_property(self, pspec): name = pspec.name.replace('-', '_') diff --git a/gi/_gobject/pygtype.c b/gi/_gobject/pygtype.c index 0b920f6..9dc1153 100644 --- a/gi/_gobject/pygtype.c +++ b/gi/_gobject/pygtype.c @@ -1362,7 +1362,7 @@ pyg_closure_marshal(GClosure *closure, goto out; } - if (return_value && pyg_value_from_pyobject(return_value, ret) != 0) { + if (G_IS_VALUE(return_value) && pyg_value_from_pyobject(return_value, ret) != 0) { /* If we already have an exception set, use that, otherwise set a * generic one */ if (!PyErr_Occurred()) @@ -1543,7 +1543,7 @@ pyg_signal_class_closure_marshal(GClosure *closure, } Py_DECREF(method); Py_DECREF(params); - if (return_value) + if (G_IS_VALUE(return_value)) pyg_value_from_pyobject(return_value, ret); Py_DECREF(ret); pyglib_gil_state_release(state); diff --git a/gi/overrides/GObject.py b/gi/overrides/GObject.py index 044c36e..b3aad47 100644 --- a/gi/overrides/GObject.py +++ b/gi/overrides/GObject.py @@ -425,20 +425,21 @@ def signal_query(id_or_name, type_=None): __all__.append('signal_query') +# Check needed for glib versions which annotate signal related methods +# with a void pointer instead of GObject.Object. +# See: https://bugzilla.gnome.org/show_bug.cgi?id=685387 +_is_first_signal_arg_void = GObjectModule.signal_stop_emission.get_arguments()[0].get_pytype_hint() == 'void' + + def _get_instance_for_signal(obj): - if isinstance(obj, GObjectModule.Object): + if not _is_first_signal_arg_void: + return obj + elif isinstance(obj, GObjectModule.Object): return obj.__gpointer__ else: raise TypeError('Unsupported object "%s" for signal function' % obj) -def _wrap_signal_func(func): - @functools.wraps(func) - def wrapper(obj, *args, **kwargs): - return func(_get_instance_for_signal(obj), *args, **kwargs) - return wrapper - - class _HandlerBlockManager(object): def __init__(self, obj, handler_id): self.obj = obj @@ -466,32 +467,47 @@ def signal_handler_block(obj, handler_id): __all__.append('signal_handler_block') -# The following functions wrap GI functions but coerce the first arg into -# something compatible with gpointer - -signal_handler_unblock = _wrap_signal_func(GObjectModule.signal_handler_unblock) -signal_handler_disconnect = _wrap_signal_func(GObjectModule.signal_handler_disconnect) -signal_handler_is_connected = _wrap_signal_func(GObjectModule.signal_handler_is_connected) -signal_stop_emission = _wrap_signal_func(GObjectModule.signal_stop_emission) -signal_stop_emission_by_name = _wrap_signal_func(GObjectModule.signal_stop_emission_by_name) -signal_has_handler_pending = _wrap_signal_func(GObjectModule.signal_has_handler_pending) -signal_get_invocation_hint = _wrap_signal_func(GObjectModule.signal_get_invocation_hint) -signal_connect_closure = _wrap_signal_func(GObjectModule.signal_connect_closure) -signal_connect_closure_by_id = _wrap_signal_func(GObjectModule.signal_connect_closure_by_id) -signal_handler_find = _wrap_signal_func(GObjectModule.signal_handler_find) -signal_handlers_destroy = _wrap_signal_func(GObjectModule.signal_handlers_destroy) -signal_handlers_block_matched = _wrap_signal_func(GObjectModule.signal_handlers_block_matched) -signal_handlers_unblock_matched = _wrap_signal_func(GObjectModule.signal_handlers_unblock_matched) -signal_handlers_disconnect_matched = _wrap_signal_func(GObjectModule.signal_handlers_disconnect_matched) - -__all__ += ['signal_handler_unblock', - 'signal_handler_disconnect', 'signal_handler_is_connected', - 'signal_stop_emission', 'signal_stop_emission_by_name', - 'signal_has_handler_pending', 'signal_get_invocation_hint', - 'signal_connect_closure', 'signal_connect_closure_by_id', - 'signal_handler_find', 'signal_handlers_destroy', - 'signal_handlers_block_matched', 'signal_handlers_unblock_matched', - 'signal_handlers_disconnect_matched'] +if _is_first_signal_arg_void: + # The following functions wrap GI functions but coerce the first arg into + # something compatible with gpointer + + def _wrap_signal_func(func): + @functools.wraps(func) + def wrapper(obj, *args, **kwargs): + return func(_get_instance_for_signal(obj), *args, **kwargs) + return wrapper + + signal_handler_unblock = _wrap_signal_func(GObjectModule.signal_handler_unblock) + signal_handler_disconnect = _wrap_signal_func(GObjectModule.signal_handler_disconnect) + signal_handler_is_connected = _wrap_signal_func(GObjectModule.signal_handler_is_connected) + signal_stop_emission = _wrap_signal_func(GObjectModule.signal_stop_emission) + signal_stop_emission_by_name = _wrap_signal_func(GObjectModule.signal_stop_emission_by_name) + signal_has_handler_pending = _wrap_signal_func(GObjectModule.signal_has_handler_pending) + signal_get_invocation_hint = _wrap_signal_func(GObjectModule.signal_get_invocation_hint) + signal_connect_closure = _wrap_signal_func(GObjectModule.signal_connect_closure) + signal_connect_closure_by_id = _wrap_signal_func(GObjectModule.signal_connect_closure_by_id) + signal_handler_find = _wrap_signal_func(GObjectModule.signal_handler_find) + signal_handlers_destroy = _wrap_signal_func(GObjectModule.signal_handlers_destroy) + signal_handlers_block_matched = _wrap_signal_func(GObjectModule.signal_handlers_block_matched) + signal_handlers_unblock_matched = _wrap_signal_func(GObjectModule.signal_handlers_unblock_matched) + signal_handlers_disconnect_matched = _wrap_signal_func(GObjectModule.signal_handlers_disconnect_matched) + + __all__ += ['signal_handler_unblock', + 'signal_handler_disconnect', 'signal_handler_is_connected', + 'signal_stop_emission', 'signal_stop_emission_by_name', + 'signal_has_handler_pending', 'signal_get_invocation_hint', + 'signal_connect_closure', 'signal_connect_closure_by_id', + 'signal_handler_find', 'signal_handlers_destroy', + 'signal_handlers_block_matched', 'signal_handlers_unblock_matched', + 'signal_handlers_disconnect_matched'] +else: + # First signal arg is GObject.Object but we need these as globals for + # our GObject.Object class override below + signal_handler_disconnect = GObjectModule.signal_handler_disconnect + signal_handler_unblock = GObjectModule.signal_handler_unblock + signal_handler_disconnect = GObjectModule.signal_handler_disconnect + signal_handler_is_connected = GObjectModule.signal_handler_is_connected + signal_stop_emission_by_name = GObjectModule.signal_stop_emission_by_name def signal_parse_name(detailed_signal, itype, force_detail_quark): @@ -556,6 +572,16 @@ class _FreezeNotifyManager(object): self.obj.thaw_notify() +def _signalmethod(func): + # Function wrapper for signal functions used as instance methods. + # This is needed when the signal functions come directly from GI. + # (they are not already wrapped) + @functools.wraps(func) + def meth(*args, **kwargs): + return func(*args, **kwargs) + return meth + + class Object(GObjectModule.Object): def _unsupported_method(self, *args, **kargs): raise RuntimeError('This method is currently unsupported.') @@ -635,12 +661,12 @@ class Object(GObjectModule.Object): # Aliases # - disconnect = signal_handler_disconnect - handler_block = signal_handler_block - handler_unblock = signal_handler_unblock - handler_disconnect = signal_handler_disconnect - handler_is_connected = signal_handler_is_connected - stop_emission_by_name = signal_stop_emission_by_name + disconnect = _signalmethod(signal_handler_disconnect) + handler_block = _signalmethod(signal_handler_block) + handler_unblock = _signalmethod(signal_handler_unblock) + handler_disconnect = _signalmethod(signal_handler_disconnect) + handler_is_connected = _signalmethod(signal_handler_is_connected) + stop_emission_by_name = _signalmethod(signal_stop_emission_by_name) # # Deprecated Methods diff --git a/gi/pygi-closure.c b/gi/pygi-closure.c index 7582069..2f5548a 100644 --- a/gi/pygi-closure.c +++ b/gi/pygi-closure.c @@ -33,10 +33,11 @@ _pygi_closure_assign_pyobj_to_retval (gpointer retval, PyObject *object, GITransfer transfer) { GIArgument arg = _pygi_argument_from_object (object, type_info, transfer); + GITypeTag type_tag; if (PyErr_Occurred ()) return; - GITypeTag type_tag = g_type_info_get_tag (type_info); + type_tag = g_type_info_get_tag (type_info); if (retval == NULL) return; diff --git a/gi/pygi-marshal-from-py.c b/gi/pygi-marshal-from-py.c index a48479b..82d94a0 100644 --- a/gi/pygi-marshal-from-py.c +++ b/gi/pygi-marshal-from-py.c @@ -1827,7 +1827,13 @@ _pygi_marshal_from_py_interface_struct (PyObject *py_arg, } if (g_type_is_a (g_type, G_TYPE_BOXED)) { - if (pyg_boxed_check (py_arg, g_type)) { + /* Use pyg_type_from_object to pull the stashed __gtype__ attribute + * off of the input argument instead of checking PyGBoxed.gtype + * with pyg_boxed_check. This is needed to work around type discrepancies + * in cases with aliased (typedef) types. e.g. GtkAllocation, GdkRectangle. + * See: https://bugzilla.gnomethere are .org/show_bug.cgi?id=707140 + */ + if (g_type_is_a (pyg_type_from_object (py_arg), g_type)) { arg->v_pointer = pyg_boxed_get (py_arg, void); if (transfer == GI_TRANSFER_EVERYTHING) { arg->v_pointer = g_boxed_copy (g_type, arg->v_pointer); diff --git a/gi/pygi-signal-closure.c b/gi/pygi-signal-closure.c index 20c6b56..bcd1320 100644 --- a/gi/pygi-signal-closure.c +++ b/gi/pygi-signal-closure.c @@ -155,7 +155,7 @@ pygi_signal_closure_marshal(GClosure *closure, goto out; } - if (return_value && pyg_value_from_pyobject(return_value, ret) != 0) { + if (G_IS_VALUE(return_value) && pyg_value_from_pyobject(return_value, ret) != 0) { PyErr_SetString(PyExc_TypeError, "can't convert return value to desired type"); diff --git a/tests/test_overrides_gtk.py b/tests/test_overrides_gtk.py index f9d21c2..fbe51ec 100644 --- a/tests/test_overrides_gtk.py +++ b/tests/test_overrides_gtk.py @@ -590,6 +590,40 @@ class TestGtk(unittest.TestCase): @unittest.skipUnless(Gtk, 'Gtk not available') +class TestSignals(unittest.TestCase): + class WindowWithSizeAllocOverride(Gtk.ScrolledWindow): + __gsignals__ = {'size-allocate': 'override'} + + def __init__(self): + Gtk.ScrolledWindow.__init__(self) + self._alloc_called = False + self._alloc_value = None + self._alloc_error = None + + def do_size_allocate(self, alloc): + self._alloc_called = True + self._alloc_value = alloc + + try: + Gtk.ScrolledWindow.do_size_allocate(self, alloc) + except Exception as e: + self._alloc_error = e + + def test_class_closure_override_with_aliased_type(self): + win = self.WindowWithSizeAllocOverride() + rect = Gdk.Rectangle() + rect.width = 100 + rect.height = 100 + + with realized(win): + win.show() + win.size_allocate(rect) + self.assertTrue(win._alloc_called) + self.assertIsInstance(win._alloc_value, Gdk.Rectangle) + self.assertTrue(win._alloc_error is None, win._alloc_error) + + +@unittest.skipUnless(Gtk, 'Gtk not available') class TestBuilder(unittest.TestCase): class SignalTest(GObject.GObject): __gtype_name__ = "GIOverrideSignalTest" |