From 2d8c9073fa23a0fde76a3b8ecf8cb518d162d101 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Wed, 12 Jul 2017 08:49:57 +0900 Subject: [PATCH] Imported Upstream version 3.9.2 Change-Id: Ie80410930b36515756001676d161cf070c996619 Signed-off-by: DongHun Kwak --- ChangeLog | 138 ++++++++++++++++++++++++++++++++++++++++ NEWS | 15 +++++ PKG-INFO | 4 +- aclocal.m4 | 6 +- configure | 30 +++++---- configure.ac | 2 +- examples/option.py | 38 +++++------ gi/_glib/pyglib.c | 41 ------------ gi/_glib/pyglib.h | 13 ++-- gi/_glib/pygoptioncontext.c | 4 +- gi/_gobject/gobjectmodule.c | 25 +++----- gi/_gobject/pygobject-private.h | 33 ---------- gi/_gobject/pygobject.c | 33 +++++----- gi/_gobject/pygobject.h | 48 +++++++------- gi/gimodule.c | 15 +++-- gi/pygi-boxed.c | 4 -- gi/pygi-closure.c | 3 +- gi/pygi-info.c | 20 ++---- gi/pygi-invoke.c | 4 +- gi/pygi-struct.c | 4 -- gi/types.py | 12 ++-- tests/test_gi.py | 22 +++++++ 22 files changed, 297 insertions(+), 217 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5b8ef91..c761345 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,141 @@ +commit af8d048442b924c72a1d0ae868ee63ccf292759d +Author: Martin Pitt +Date: Fri May 24 13:03:07 2013 +0200 + + examples/option.py: Port to GI and Python 3 + + examples/option.py | 38 +++++++++++++++++++------------------- + 1 file changed, 19 insertions(+), 19 deletions(-) + +commit bef5939ca77f4d6939cd9229bd124dfe825b3bdb +Author: Simon Feltman +Date: Sun May 12 18:58:06 2013 -0700 + + Fix vfunc info search for classes with multiple inheritance + + Ensure the search for vfunc GI info continues recursively even if the + current class being looked at does not contain GI info of type + InterfaceInfo. This more exhaustive search is needed for setups with + multiple sub-classes and multiple inheritance. + + https://bugzilla.gnome.org/show_bug.cgi?id=700092 + + gi/types.py | 12 +++++++----- + tests/test_gi.py | 1 - + 2 files changed, 7 insertions(+), 6 deletions(-) + +commit 5b8dff59baa1a3e524dac7877dd5b33dea52b026 +Author: Simon Feltman +Date: Sun May 12 22:19:38 2013 -0700 + + Fix closure argument conversion for enum and flag in args + + Replace incorrect cast and assignment of double with uint for flags + and enums. + + gi/pygi-closure.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 065503d5e284dc89bacd79d0d9a72eb739882bf8 +Author: Simon Feltman +Date: Sat May 11 21:47:54 2013 -0700 + + tests: Add tests for overriding vfunc implementations + + Add tests for overriding vfuncs for both single inheritance + and multiple inheritance with an interface (currently failing). + + https://bugzilla.gnome.org/show_bug.cgi?id=700092 + + tests/test_gi.py | 23 +++++++++++++++++++++++ + 1 file changed, 23 insertions(+) + +commit c4e1112840004af264b4f2a052f333ea38f95cb6 +Author: Simon Feltman +Date: Sat May 11 20:28:22 2013 -0700 + + Fix marshaling Python to FFI return value for enum and flags + + Add break to GI_TYPE_TAG_INTERFACE case. This was falling through + causing + assignment of arg.v_pointer to the ffi return arg. + + gi/pygi-closure.c | 1 + + 1 file changed, 1 insertion(+) + +commit a703217eaf4075e9720d4247351e1dfc4f553772 +Author: Simon Feltman +Date: Fri Apr 19 06:37:24 2013 -0700 + + Remove half implemented GC in PyGIBaseInfo, PyGIStruct, and PyGIBoxed + + Remove half implemented GC tracking from PyGIBaseInfo as it was not + needed (the implemented was also missing usage of + PyObject_GC_New/Track). + Ensure weakref list for PyGIBaseInfo is initialized to NULL and + cleared + properly. + Remove invalid calls to PyObject_GC_UnTrack and PyObject_ClearWeakRefs + for both PyGIStruct and PyGIBoxed as these types were not being + advertised as GC aware with Py_TPFLAGS_HAVE_GC. + + https://bugzilla.gnome.org/show_bug.cgi?id=677091 + + gi/pygi-boxed.c | 4 ---- + gi/pygi-info.c | 20 +++++--------------- + gi/pygi-struct.c | 4 ---- + 3 files changed, 5 insertions(+), 23 deletions(-) + +commit 87e41db2e060acd689a2ac043bc1ac51007de6f3 +Author: Simon Feltman +Date: Fri May 3 02:00:07 2013 -0700 + + Replace usage of pyg_begin_allow_threads with Py_BEGIN_ALLOW_THREADS + + Replace all usage of pyg[lib]_begin_allow_threads with direct usage + of Py_BEGIN_ALLOW_THREADS. + + https://bugzilla.gnome.org/show_bug.cgi?id=699440 + + gi/_glib/pyglib.h | 4 ---- + gi/_glib/pygoptioncontext.c | 4 ++-- + gi/_gobject/pygobject.c | 33 ++++++++++++++++----------------- + gi/gimodule.c | 4 ++-- + gi/pygi-invoke.c | 4 ++-- + 5 files changed, 22 insertions(+), 27 deletions(-) + +commit c9e95663d05de98a9abd3d1479554b1f09753382 +Author: Simon Feltman +Date: Thu May 2 03:57:05 2013 -0700 + + Remove and deprecate API for setting of thread blocking functions + + Remove pyglib_set_thread_block_funcs and deprecate + pyg_set_thread_block_funcs. + The thread block function APIs are no longer be neccessary because + PyGObject + can use the Python C API directly when working with threads. + + https://bugzilla.gnome.org/show_bug.cgi?id=699440 + + gi/_glib/pyglib.c | 41 ----------------------------------- + gi/_glib/pyglib.h | 9 ++++---- + gi/_gobject/gobjectmodule.c | 25 ++++++++------------- + gi/_gobject/pygobject-private.h | 33 ---------------------------- + gi/_gobject/pygobject.h | 48 + ++++++++++++++++++++--------------------- + gi/gimodule.c | 15 +++++++------ + 6 files changed, 46 insertions(+), 125 deletions(-) + +commit 05498a5732582a5ed1944bd1383af154ca5fc4e6 +Author: Martin Pitt +Date: Tue Apr 30 11:51:05 2013 -0700 + + configure.ac: Post-release bump to 3.9.2 + + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + commit 902bb6685fd9c90c7d81127861a152b0fab4b107 Author: Martin Pitt Date: Tue Apr 30 11:49:03 2013 -0700 diff --git a/NEWS b/NEWS index 6ecd417..6f9ad54 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,18 @@ +3.9.2 28-May-2013 + - examples/option.py: Port to GI and Python 3 (Martin Pitt) + - Fix vfunc info search for classes with multiple inheritance + (Simon Feltman) (#700092) + - Fix closure argument conversion for enum and flag in args + (Simon Feltman) + - Fix marshaling Python to FFI return value for enum and flags + (Simon Feltman) + - Remove half implemented GC in PyGIBaseInfo, PyGIStruct, and PyGIBoxed + (Simon Feltman) (#677091) + - Replace usage of pyg_begin_allow_threads with Py_BEGIN_ALLOW_THREADS + (Simon Feltman) (#699440) + - Remove and deprecate API for setting of thread blocking functions + (Simon Feltman) (#699440) + 3.9.1 30-Apr-2013 - gtk-demo: Wrap description strings at 80 characters (Simon Feltman) (#698547) diff --git a/PKG-INFO b/PKG-INFO index ea9c30e..205fc85 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: PyGObject -Version: 3.9.1 +Version: 3.9.2 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.1.tar.gz +Download-url: ftp://ftp.gnome.org/pub/GNOME/sources/pygobject/3.9/pygobject-3.9.2.tar.gz Description: Python bindings for GLib and GObject Platform: POSIX, Windows Classifier: Development Status :: 5 - Production/Stable diff --git a/aclocal.m4 b/aclocal.m4 index cbd58f8..fa6bf8f 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1780,7 +1780,7 @@ code_coverage_quiet_0 = --quiet # Use recursive makes in order to ignore errors during check check-code-coverage: -ifdef CODE_COVERAGE_ENABLED +ifeq ($(CODE_COVERAGE_ENABLED),yes) -$(MAKE) $(AM_MAKEFLAGS) -k check $(MAKE) $(AM_MAKEFLAGS) code-coverage-capture else @@ -1789,7 +1789,7 @@ endif # Capture code coverage data code-coverage-capture: code-coverage-capture-hook -ifdef CODE_COVERAGE_ENABLED +ifeq ($(CODE_COVERAGE_ENABLED),yes) $(LCOV) $(code_coverage_quiet) --directory $(CODE_COVERAGE_DIRECTORY) --capture --output-file "$(CODE_COVERAGE_OUTPUT_FILE).tmp" --test-name "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" --no-checksum --compat-libtool $(CODE_COVERAGE_LCOV_OPTIONS) $(LCOV) $(code_coverage_quiet) --directory $(CODE_COVERAGE_DIRECTORY) --remove "$(CODE_COVERAGE_OUTPUT_FILE).tmp" "/tmp/*" $(CODE_COVERAGE_IGNORE_PATTERN) --output-file "$(CODE_COVERAGE_OUTPUT_FILE)" -@rm -f $(CODE_COVERAGE_OUTPUT_FILE).tmp @@ -1802,11 +1802,13 @@ endif # Hook rule executed before code-coverage-capture, overridable by the user code-coverage-capture-hook: +ifeq ($(CODE_COVERAGE_ENABLED),yes) clean: code-coverage-clean code-coverage-clean: -$(LCOV) --directory $(top_builddir) -z -rm -rf $(CODE_COVERAGE_OUTPUT_FILE) $(CODE_COVERAGE_OUTPUT_FILE).tmp $(CODE_COVERAGE_OUTPUT_DIRECTORY) -find . -name "*.gcda" -o -name "*.gcov" -delete +endif GITIGNOREFILES ?= GITIGNOREFILES += $(CODE_COVERAGE_OUTPUT_FILE) $(CODE_COVERAGE_OUTPUT_DIRECTORY) diff --git a/configure b/configure index 502ffe7..6f0fd68 100755 --- a/configure +++ b/configure @@ -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.1. +# Generated by GNU Autoconf 2.69 for pygobject 3.9.2. # # Report bugs to . # @@ -591,8 +591,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='pygobject' PACKAGE_TARNAME='pygobject' -PACKAGE_VERSION='3.9.1' -PACKAGE_STRING='pygobject 3.9.1' +PACKAGE_VERSION='3.9.2' +PACKAGE_STRING='pygobject 3.9.2' 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.1 to adapt to many kinds of systems. +\`configure' configures pygobject 3.9.2 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.1:";; + short | recursive ) echo "Configuration of pygobject 3.9.2:";; esac cat <<\_ACEOF @@ -1600,7 +1600,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -pygobject configure 3.9.1 +pygobject configure 3.9.2 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1878,7 +1878,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.1, which was +It was created by pygobject $as_me 3.9.2, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2242,9 +2242,9 @@ $as_echo "#define PYGOBJECT_MINOR_VERSION 9" >>confdefs.h PYGOBJECT_MINOR_VERSION=9 -$as_echo "#define PYGOBJECT_MICRO_VERSION 1" >>confdefs.h +$as_echo "#define PYGOBJECT_MICRO_VERSION 2" >>confdefs.h -PYGOBJECT_MICRO_VERSION=1 +PYGOBJECT_MICRO_VERSION=2 ac_config_headers="$ac_config_headers config.h" @@ -2755,7 +2755,7 @@ fi # Define the identity of the package. PACKAGE='pygobject' - VERSION='3.9.1' + VERSION='3.9.2' cat >>confdefs.h <<_ACEOF @@ -14532,7 +14532,7 @@ code_coverage_quiet_0 = --quiet # Use recursive makes in order to ignore errors during check check-code-coverage: -ifdef CODE_COVERAGE_ENABLED +ifeq ($(CODE_COVERAGE_ENABLED),yes) -$(MAKE) $(AM_MAKEFLAGS) -k check $(MAKE) $(AM_MAKEFLAGS) code-coverage-capture else @@ -14541,7 +14541,7 @@ endif # Capture code coverage data code-coverage-capture: code-coverage-capture-hook -ifdef CODE_COVERAGE_ENABLED +ifeq ($(CODE_COVERAGE_ENABLED),yes) $(LCOV) $(code_coverage_quiet) --directory $(CODE_COVERAGE_DIRECTORY) --capture --output-file "$(CODE_COVERAGE_OUTPUT_FILE).tmp" --test-name "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" --no-checksum --compat-libtool $(CODE_COVERAGE_LCOV_OPTIONS) $(LCOV) $(code_coverage_quiet) --directory $(CODE_COVERAGE_DIRECTORY) --remove "$(CODE_COVERAGE_OUTPUT_FILE).tmp" "/tmp/*" $(CODE_COVERAGE_IGNORE_PATTERN) --output-file "$(CODE_COVERAGE_OUTPUT_FILE)" -@rm -f $(CODE_COVERAGE_OUTPUT_FILE).tmp @@ -14554,11 +14554,13 @@ endif # Hook rule executed before code-coverage-capture, overridable by the user code-coverage-capture-hook: +ifeq ($(CODE_COVERAGE_ENABLED),yes) clean: code-coverage-clean code-coverage-clean: -$(LCOV) --directory $(top_builddir) -z -rm -rf $(CODE_COVERAGE_OUTPUT_FILE) $(CODE_COVERAGE_OUTPUT_FILE).tmp $(CODE_COVERAGE_OUTPUT_DIRECTORY) -find . -name "*.gcda" -o -name "*.gcov" -delete +endif GITIGNOREFILES ?= GITIGNOREFILES += $(CODE_COVERAGE_OUTPUT_FILE) $(CODE_COVERAGE_OUTPUT_DIRECTORY) @@ -15267,7 +15269,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.1, which was +This file was extended by pygobject $as_me 3.9.2, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -15334,7 +15336,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.1 +pygobject config.status 3.9.2 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 2458975..350c811 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, 1) +m4_define(pygobject_micro_version, 2) m4_define(pygobject_version, pygobject_major_version.pygobject_minor_version.pygobject_micro_version) dnl versions of packages we require ... diff --git a/examples/option.py b/examples/option.py index 04838b1..73860f5 100644 --- a/examples/option.py +++ b/examples/option.py @@ -1,28 +1,28 @@ #!/usr/bin/env python -# gnome-python/pygobject/examples/option.py -from gobject.option import OptionGroup, OptionParser, make_option +from gi.repository import GLib -group = OptionGroup("example", "OptionGroup Example", "Shows all example options", - option_list=[make_option("--example", - action="store_true", - dest="example", - help="An example option."), - ]) +group = GLib.option.OptionGroup( + "example", "OptionGroup Example", "Shows all example options", + option_list=[GLib.option.make_option("--example", + action="store_true", + dest="example", + help="An example option."), + ]) -parser = OptionParser("NAMES ...", - description="A simple gobject.option example.", - option_list=[make_option("--file", "-f", - type="filename", - action="store", - dest="file", - help="A filename option"), - # ... - ]) +parser = GLib.option.OptionParser( + "NAMES ...", description="A simple gobject.option example.", + option_list=[GLib.option.make_option("--file", "-f", + type="filename", + action="store", + dest="file", + help="A filename option"), + # ... + ]) parser.add_option_group(group) parser.parse_args() -print "group: example ", group.values.example -print "parser: file", parser.values.file +print("group: example " + str(group.values.example)) +print("parser: file " + str(parser.values.file)) diff --git a/gi/_glib/pyglib.c b/gi/_glib/pyglib.c index 54b2d90..9753a52 100644 --- a/gi/_glib/pyglib.c +++ b/gi/_glib/pyglib.c @@ -77,47 +77,6 @@ pyglib_init_internal(PyObject *api) } /** - * pyglib_block_threads: - * - */ -void -pyglib_block_threads(void) -{ - g_return_if_fail (_PyGLib_API != NULL); - - if (_PyGLib_API->block_threads != NULL) - (* _PyGLib_API->block_threads)(); -} - -/** - * pyglib_unblock_threads: - * - */ -void -pyglib_unblock_threads(void) -{ - g_return_if_fail (_PyGLib_API != NULL); - if (_PyGLib_API->unblock_threads != NULL) - (* _PyGLib_API->unblock_threads)(); -} - -/** - * pyglib_set_thread_block_funcs: - * - * hooks to register handlers for getting GDK threads to cooperate - * with python threading - */ -void -pyglib_set_thread_block_funcs (PyGLibThreadBlockFunc block_threads_func, - PyGLibThreadBlockFunc unblock_threads_func) -{ - g_return_if_fail (_PyGLib_API != NULL); - - _PyGLib_API->block_threads = block_threads_func; - _PyGLib_API->unblock_threads = unblock_threads_func; -} - -/** * pyglib_error_marshal: * @error: a pointer to the GError. * diff --git a/gi/_glib/pyglib.h b/gi/_glib/pyglib.h index 0b587b8..1c62f1d 100644 --- a/gi/_glib/pyglib.h +++ b/gi/_glib/pyglib.h @@ -37,24 +37,21 @@ void pyglib_init_internal(PyObject *api); #ifdef DISABLE_THREADING # define pyglib_gil_state_ensure() PyGILState_LOCKED # define pyglib_gil_state_release(state) state -# define pyglib_begin_allow_threads G_STMT_START { -# define pyglib_end_allow_threads } G_STMT_END #else # define pyglib_gil_state_ensure PyGILState_Ensure # define pyglib_gil_state_release PyGILState_Release -# define pyglib_begin_allow_threads Py_BEGIN_ALLOW_THREADS -# define pyglib_end_allow_threads Py_END_ALLOW_THREADS #endif +/* Deprecated, only available for API compatibility. */ +#define pyg_set_thread_block_funcs(a, b) +#define pyglib_block_threads() +#define pyglib_unblock_threads() + gboolean pyglib_error_check(GError **error); PyObject *pyglib_error_marshal (GError **error); gboolean pyglib_gerror_exception_check(GError **error); PyObject *pyglib_register_exception_for_domain(gchar *name, gint error_domain); -void pyglib_set_thread_block_funcs(PyGLibThreadBlockFunc block_threads_func, - PyGLibThreadBlockFunc unblock_threads_func); -void pyglib_block_threads(void); -void pyglib_unblock_threads(void); PyObject * pyglib_option_context_new(GOptionContext *context); PyObject * pyglib_option_group_new(GOptionGroup *group); GOptionGroup * pyglib_option_group_transfer_group(PyObject *self); diff --git a/gi/_glib/pygoptioncontext.c b/gi/_glib/pygoptioncontext.c index b985dbe..8ecbff8 100644 --- a/gi/_glib/pygoptioncontext.c +++ b/gi/_glib/pygoptioncontext.c @@ -130,10 +130,10 @@ pyg_option_context_parse(PyGOptionContext *self, g_assert(argv_length <= G_MAXINT); argv_length_int = argv_length; - pyglib_begin_allow_threads; + Py_BEGIN_ALLOW_THREADS; result = g_option_context_parse(self->context, &argv_length_int, &argv_content, &error); - pyglib_end_allow_threads; + Py_END_ALLOW_THREADS; argv_length = argv_length_int; if (!result) diff --git a/gi/_gobject/gobjectmodule.c b/gi/_gobject/gobjectmodule.c index 3de839d..1e1cbd8 100644 --- a/gi/_gobject/gobjectmodule.c +++ b/gi/_gobject/gobjectmodule.c @@ -48,24 +48,17 @@ static void pyg_flags_add_constants(PyObject *module, GType flags_type, /** * pyg_set_thread_block_funcs: - * @block_threads_func: a function to block Python threads. - * @unblock_threads_func: a function to unblock Python threads. - * - * an interface to allow pygtk to add hooks to handle threading - * similar to the old PyGTK 0.6.x releases. May not work quite right - * anymore. + * Deprecated, only available for ABI compatibility. */ static void -pyg_set_thread_block_funcs (PyGThreadBlockFunc block_threads_func, - PyGThreadBlockFunc unblock_threads_func) +_pyg_set_thread_block_funcs (PyGThreadBlockFunc block_threads_func, + PyGThreadBlockFunc unblock_threads_func) { - g_return_if_fail(pygobject_api_functions.block_threads == NULL && - pygobject_api_functions.unblock_threads == NULL); - - pygobject_api_functions.block_threads = block_threads_func; - pygobject_api_functions.unblock_threads = unblock_threads_func; - pyglib_set_thread_block_funcs(block_threads_func, - unblock_threads_func); + PyGILState_STATE state = pyglib_gil_state_ensure (); + PyErr_Warn (PyExc_DeprecationWarning, + "Using pyg_set_thread_block_funcs is not longer needed. " + "PyGObject always uses Py_BLOCK/UNBLOCK_THREADS."); + pyglib_gil_state_release (state); } /** @@ -2031,7 +2024,7 @@ struct _PyGObject_Functions pygobject_api_functions = { pyg_error_check, - pyg_set_thread_block_funcs, + _pyg_set_thread_block_funcs, (PyGThreadBlockFunc)0, /* block_threads */ (PyGThreadBlockFunc)0, /* unblock_threads */ diff --git a/gi/_gobject/pygobject-private.h b/gi/_gobject/pygobject-private.h index 5de7488..e2a0af7 100644 --- a/gi/_gobject/pygobject-private.h +++ b/gi/_gobject/pygobject-private.h @@ -21,39 +21,6 @@ /* from gobjectmodule.c */ extern struct _PyGObject_Functions pygobject_api_functions; -#define pyg_block_threads() G_STMT_START { \ - if (pygobject_api_functions.block_threads != NULL) \ - (* pygobject_api_functions.block_threads)(); \ - } G_STMT_END -#define pyg_unblock_threads() G_STMT_START { \ - if (pygobject_api_functions.unblock_threads != NULL) \ - (* pygobject_api_functions.unblock_threads)(); \ - } G_STMT_END - -#define pyg_threads_enabled (pygobject_api_functions.threads_enabled) - -#ifdef DISABLE_THREADING -#define pyg_gil_state_ensure() 0 -#define pyg_gil_state_release(state) G_STMT_START { \ - } G_STMT_END - -#else -#define pyg_gil_state_ensure() (pygobject_api_functions.threads_enabled? (PyGILState_Ensure()) : 0) -#define pyg_gil_state_release(state) G_STMT_START { \ - if (pygobject_api_functions.threads_enabled) \ - PyGILState_Release(state); \ - } G_STMT_END -#endif - -#define pyg_begin_allow_threads \ - G_STMT_START { \ - PyThreadState *_save = NULL; \ - if (pygobject_api_functions.threads_enabled) \ - _save = PyEval_SaveThread(); -#define pyg_end_allow_threads \ - if (pygobject_api_functions.threads_enabled) \ - PyEval_RestoreThread(_save); \ - } G_STMT_END #ifndef Py_CLEAR /* since Python 2.4 */ diff --git a/gi/_gobject/pygobject.c b/gi/_gobject/pygobject.c index 4ca360a..875da17 100644 --- a/gi/_gobject/pygobject.c +++ b/gi/_gobject/pygobject.c @@ -88,10 +88,9 @@ pygobject_data_free(PyGObjectData *data) if (Py_IsInitialized()) { state = pyglib_gil_state_ensure(); Py_DECREF(data->type); - /* We cannot use pyg_begin_allow_threads here because this is inside + /* We cannot use Py_BEGIN_ALLOW_THREADS here because this is inside * a branch. */ - if (pyg_threads_enabled) - _save = PyEval_SaveThread(); + Py_UNBLOCK_THREADS; /* Modifies _save */ } tmp = closures = data->closures; @@ -114,8 +113,7 @@ pygobject_data_free(PyGObjectData *data) g_free(data); if (Py_IsInitialized()) { - if (pyg_threads_enabled) - PyEval_RestoreThread(_save); + Py_BLOCK_THREADS; /* Restores _save */ pyglib_gil_state_release(state); } } @@ -309,10 +307,11 @@ PyGProps_getattro(PyGProps *self, PyObject *attr) /* The GType is implemented in Python, or we failed to read it via gi: * do a straightforward read. */ + Py_BEGIN_ALLOW_THREADS; g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec)); - pyg_begin_allow_threads; g_object_get_property(self->pygobject->obj, pspec->name, &value); - pyg_end_allow_threads; + Py_END_ALLOW_THREADS; + ret = pyg_param_gvalue_as_pyobject(&value, TRUE, pspec); g_value_unset(&value); @@ -352,12 +351,11 @@ set_property_from_pspec(GObject *obj, return FALSE; } - pyg_begin_allow_threads; + Py_BEGIN_ALLOW_THREADS; g_object_set_property(obj, pspec->name, &value); - pyg_end_allow_threads; - g_value_unset(&value); - + Py_END_ALLOW_THREADS; + return TRUE; } @@ -1183,9 +1181,9 @@ pygobject_clear(PyGObject *self) g_object_remove_toggle_ref(self->obj, pyg_toggle_notify, self); self->private_flags.flags &= ~PYGOBJECT_USING_TOGGLE_REF; } else { - pyg_begin_allow_threads; + Py_BEGIN_ALLOW_THREADS; g_object_unref(self->obj); - pyg_end_allow_threads; + Py_END_ALLOW_THREADS; } self->obj = NULL; } @@ -1320,9 +1318,10 @@ pygobject_get_property(PyGObject *self, PyObject *args) return NULL; } g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec)); - pyg_begin_allow_threads; + Py_BEGIN_ALLOW_THREADS; g_object_get_property(self->obj, param_name, &value); - pyg_end_allow_threads; + Py_END_ALLOW_THREADS; + ret = pyg_param_gvalue_as_pyobject(&value, TRUE, pspec); g_value_unset(&value); return ret; @@ -1372,9 +1371,9 @@ pygobject_get_properties(PyGObject *self, PyObject *args) } g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec)); - pyg_begin_allow_threads; + Py_BEGIN_ALLOW_THREADS; g_object_get_property(self->obj, property_name, &value); - pyg_end_allow_threads; + Py_END_ALLOW_THREADS; item = pyg_value_as_pyobject(&value, TRUE); PyTuple_SetItem(tuple, i, item); diff --git a/gi/_gobject/pygobject.h b/gi/_gobject/pygobject.h index 3c5e384..f6b531d 100644 --- a/gi/_gobject/pygobject.h +++ b/gi/_gobject/pygobject.h @@ -140,6 +140,7 @@ struct _PyGObject_Functions { PyGThreadBlockFunc unblock_threads_func); PyGThreadBlockFunc block_threads; PyGThreadBlockFunc unblock_threads; + PyTypeObject *paramspec_type; PyObject *(* paramspec_new)(GParamSpec *spec); GParamSpec *(*paramspec_get)(PyObject *tuple); @@ -196,6 +197,28 @@ struct _PyGObject_Functions { PyTypeObject *object_type; }; + +#ifdef DISABLE_THREADING +# define pyg_threads_enabled FALSE +# define pyg_gil_state_ensure() 0 +# define pyg_gil_state_release(state) +# define pyg_begin_allow_threads G_STMT_START { +# define pyg_end_allow_threads } G_STMT_END +#else +# define pyg_threads_enabled TRUE +# define pyg_gil_state_ensure PyGILState_Ensure +# define pyg_gil_state_release PyGILState_Release +# define pyg_begin_allow_threads Py_BEGIN_ALLOW_THREADS +# define pyg_end_allow_threads Py_END_ALLOW_THREADS +#endif + +/* Deprecated, only available for API compatibility. */ +#define pyg_enable_threads() +#define pyg_set_thread_block_funcs(a, b) +#define pyg_block_threads() +#define pyg_unblock_threads() + + #ifndef _INSIDE_PYGOBJECT_ #if defined(NO_IMPORT) || defined(NO_IMPORT_PYGOBJECT) @@ -233,7 +256,6 @@ struct _PyGObject_Functions *_PyGObject_API; #define pyg_flags_add_constants (_PyGObject_API->flags_add_constants) #define pyg_constant_strip_prefix (_PyGObject_API->constant_strip_prefix) #define pyg_error_check (_PyGObject_API->error_check) -#define pyg_set_thread_block_funcs (_PyGObject_API->set_thread_block_funcs) #define PyGParamSpec_Type (*_PyGObject_API->paramspec_type) #define pyg_param_spec_new (_PyGObject_API->paramspec_new) #define pyg_param_spec_from_object (_PyGObject_API->paramspec_get) @@ -247,9 +269,6 @@ struct _PyGObject_Functions *_PyGObject_API; #define PyGFlags_Type (*_PyGObject_API->flags_type) #define pyg_flags_add (_PyGObject_API->flags_add) #define pyg_flags_from_gtype (_PyGObject_API->flags_from_gtype) -#define pyg_enable_threads (_PyGObject_API->enable_threads) -#define pyg_gil_state_ensure (_PyGObject_API->gil_state_ensure) -#define pyg_gil_state_release (_PyGObject_API->gil_state_release) #define pyg_register_class_init (_PyGObject_API->register_class_init) #define pyg_register_interface_info (_PyGObject_API->register_interface_info) #define pyg_add_warning_redirection (_PyGObject_API->add_warning_redirection) @@ -257,27 +276,6 @@ struct _PyGObject_Functions *_PyGObject_API; #define pyg_gerror_exception_check (_PyGObject_API->gerror_exception_check) #define pyg_option_group_new (_PyGObject_API->option_group_new) -#define pyg_block_threads() G_STMT_START { \ - if (_PyGObject_API->block_threads != NULL) \ - (* _PyGObject_API->block_threads)(); \ - } G_STMT_END -#define pyg_unblock_threads() G_STMT_START { \ - if (_PyGObject_API->unblock_threads != NULL) \ - (* _PyGObject_API->unblock_threads)(); \ - } G_STMT_END - -#define pyg_threads_enabled (_PyGObject_API->threads_enabled) - -#define pyg_begin_allow_threads \ - G_STMT_START { \ - PyThreadState *_save = NULL; \ - if (_PyGObject_API->threads_enabled) \ - _save = PyEval_SaveThread(); -#define pyg_end_allow_threads \ - if (_PyGObject_API->threads_enabled) \ - PyEval_RestoreThread(_save); \ - } G_STMT_END - /** * pygobject_init: diff --git a/gi/gimodule.c b/gi/gimodule.c index 108fc77..5b6bc14 100644 --- a/gi/gimodule.c +++ b/gi/gimodule.c @@ -534,6 +534,7 @@ pyg_channel_read(PyObject* self, PyObject *args, PyObject *kwargs) gsize total_read = 0; GError* error = NULL; GIOStatus status = G_IO_STATUS_NORMAL; + GIOChannel *iochannel = NULL; if (!PyArg_ParseTuple (args, "Oi:pyg_channel_read", &py_iochannel, &max_count)) { return NULL; @@ -545,7 +546,9 @@ pyg_channel_read(PyObject* self, PyObject *args, PyObject *kwargs) if (max_count == 0) return PYGLIB_PyBytes_FromString(""); - + + iochannel = pyg_boxed_get (py_iochannel, GIOChannel); + while (status == G_IO_STATUS_NORMAL && (max_count == -1 || total_read < max_count)) { gsize single_read; @@ -572,11 +575,11 @@ pyg_channel_read(PyObject* self, PyObject *args, PyObject *kwargs) buf = PYGLIB_PyBytes_AsString(ret_obj) + total_read; - pyglib_unblock_threads(); - status = g_io_channel_read_chars(pyg_boxed_get (py_iochannel, GIOChannel), - buf, buf_size, &single_read, &error); - pyglib_block_threads(); - if (pyglib_error_check(&error)) + Py_BEGIN_ALLOW_THREADS; + status = g_io_channel_read_chars (iochannel, buf, buf_size, &single_read, &error); + Py_END_ALLOW_THREADS; + + if (pyglib_error_check(&error)) goto failure; total_read += single_read; diff --git a/gi/pygi-boxed.c b/gi/pygi-boxed.c index cac2b0d..5bf2c19 100644 --- a/gi/pygi-boxed.c +++ b/gi/pygi-boxed.c @@ -32,10 +32,6 @@ _boxed_dealloc (PyGIBoxed *self) { GType g_type; - PyObject_GC_UnTrack ( (PyObject *) self); - - PyObject_ClearWeakRefs ( (PyObject *) self); - if ( ( (PyGBoxed *) self)->free_on_dealloc) { if (self->slice_allocated) { g_slice_free1 (self->size, ( (PyGBoxed *) self)->boxed); diff --git a/gi/pygi-closure.c b/gi/pygi-closure.c index e70fd86..f30fa52 100644 --- a/gi/pygi-closure.c +++ b/gi/pygi-closure.c @@ -99,6 +99,7 @@ _pygi_closure_assign_pyobj_to_retval (gpointer retval, PyObject *object, } g_base_info_unref (interface_info); + break; } default: *(ffi_arg *) retval = (ffi_arg) arg.v_pointer; @@ -271,7 +272,7 @@ _pygi_closure_convert_ffi_arguments (GICallableInfo *callable_info, void **args) break; } else if (interface_type == GI_INFO_TYPE_ENUM || interface_type == GI_INFO_TYPE_FLAGS) { - g_args[i].v_double = * (double *) args[i]; + g_args[i].v_uint = * (guint *) args[i]; g_base_info_unref (interface); break; } else if (interface_type == GI_INFO_TYPE_STRUCT || diff --git a/gi/pygi-info.c b/gi/pygi-info.c index 1229d78..3e8fcb8 100644 --- a/gi/pygi-info.c +++ b/gi/pygi-info.c @@ -32,9 +32,8 @@ static void _base_info_dealloc (PyGIBaseInfo *self) { - PyObject_GC_UnTrack ( (PyObject *) self); - - PyObject_ClearWeakRefs ( (PyObject *) self); + if (self->inst_weakreflist != NULL) + PyObject_ClearWeakRefs ( (PyObject *) self); g_base_info_unref (self->info); @@ -43,14 +42,6 @@ _base_info_dealloc (PyGIBaseInfo *self) Py_TYPE( (PyObject *) self)->tp_free ( (PyObject *) self); } -static int -_base_info_traverse (PyGIBaseInfo *self, - visitproc visit, - void *arg) -{ - return 0; -} - static PyObject * _base_info_repr (PyGIBaseInfo *self) { @@ -256,6 +247,8 @@ _pygi_info_new (GIBaseInfo *info) } self->info = g_base_info_ref (info); + self->inst_weakreflist = NULL; + self->cache = NULL; return (PyObject *) self; } @@ -1746,10 +1739,7 @@ _pygi_info_register_types (PyObject *m) PyGIBaseInfo_Type.tp_dealloc = (destructor) _base_info_dealloc; PyGIBaseInfo_Type.tp_repr = (reprfunc) _base_info_repr; - PyGIBaseInfo_Type.tp_flags = (Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_HAVE_GC); - PyGIBaseInfo_Type.tp_traverse = (traverseproc) _base_info_traverse; + PyGIBaseInfo_Type.tp_flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE); PyGIBaseInfo_Type.tp_weaklistoffset = offsetof(PyGIBaseInfo, inst_weakreflist); PyGIBaseInfo_Type.tp_methods = _PyGIBaseInfo_methods; PyGIBaseInfo_Type.tp_richcompare = (richcmpfunc)_base_info_richcompare; diff --git a/gi/pygi-invoke.c b/gi/pygi-invoke.c index 0cbb9ca..ec5da91 100644 --- a/gi/pygi-invoke.c +++ b/gi/pygi-invoke.c @@ -37,7 +37,7 @@ _invoke_callable (PyGIInvokeState *state, error = NULL; - pyg_begin_allow_threads; + Py_BEGIN_ALLOW_THREADS; /* FIXME: use this for now but we can streamline the calls */ if (cache->function_type == PYGI_FUNCTION_TYPE_VFUNC) @@ -68,7 +68,7 @@ _invoke_callable (PyGIInvokeState *state, cache->n_to_py_args, &state->return_arg, &error); - pyg_end_allow_threads; + Py_END_ALLOW_THREADS; if (!retval) { g_assert (error != NULL); diff --git a/gi/pygi-struct.c b/gi/pygi-struct.c index eace77c..29ea38e 100644 --- a/gi/pygi-struct.c +++ b/gi/pygi-struct.c @@ -34,10 +34,6 @@ _struct_dealloc (PyGIStruct *self) (PyObject *) self, &PyGIStructInfo_Type); - PyObject_GC_UnTrack ( (PyObject *) self); - - PyObject_ClearWeakRefs ( (PyObject *) self); - if (info != NULL && g_struct_info_is_foreign ( (GIStructInfo *) info)) { pygi_struct_foreign_release (info, ( (PyGPointer *) self)->pointer); } else if (self->free_on_dealloc) { diff --git a/gi/types.py b/gi/types.py index c44833d..47a81d8 100644 --- a/gi/types.py +++ b/gi/types.py @@ -245,14 +245,16 @@ def find_vfunc_info_in_interface(bases, vfunc_name): # Skip bases without __info__ (static _gobject._gobject.GObject) if base is GInterface or\ not issubclass(base, GInterface) or\ - not hasattr(base, '__info__') or\ - not isinstance(base.__info__, InterfaceInfo): + not hasattr(base, '__info__'): continue - for vfunc in base.__info__.get_vfuncs(): - if vfunc.get_name() == vfunc_name: - return vfunc + # Only look at this classes vfuncs if it is an interface. + if isinstance(base.__info__, InterfaceInfo): + for vfunc in base.__info__.get_vfuncs(): + if vfunc.get_name() == vfunc_name: + return vfunc + # Recurse into the parent classes vfunc = find_vfunc_info_in_interface(base.__bases__, vfunc_name) if vfunc is not None: return vfunc diff --git a/tests/test_gi.py b/tests/test_gi.py index 2f5e8cf..1c983eb 100644 --- a/tests/test_gi.py +++ b/tests/test_gi.py @@ -2056,6 +2056,9 @@ class TestPythonGObject(unittest.TestCase): def do_method_with_default_implementation(self, int8): self.val = int8 + def do_vfunc_return_value_only(self): + return 2121 + class Interface3Impl(GObject.Object, GIMarshallingTests.Interface3): def __init__(self): GObject.Object.__init__(self) @@ -2129,6 +2132,10 @@ class TestPythonGObject(unittest.TestCase): object_.method_with_default_implementation(87) self.assertEqual(object_.val, 87) + def test_subobject_child_vfunc(self): + object_ = self.SubObject(int=1) + self.assertEqual(object_.vfunc_return_value_only(), 2121) + def test_dynamic_module(self): from gi.module import DynamicModule self.assertTrue(isinstance(GObject, DynamicModule)) @@ -2270,6 +2277,21 @@ class TestInterfaces(unittest.TestCase): GIMarshallingTests.test_interface_test_int8_in(instance, 42) self.assertEqual(instance.val, 42) + def test_subclass_override(self): + class TestInterfaceImplD(TestInterfaces.TestInterfaceImpl): + val2 = None + + def do_test_int8_in(self, int8): + self.val2 = int8 + + instance = TestInterfaceImplD() + self.assertEqual(instance.val, None) + self.assertEqual(instance.val2, None) + + GIMarshallingTests.test_interface_test_int8_in(instance, 42) + self.assertEqual(instance.val, None) + self.assertEqual(instance.val2, 42) + def test_mro(self): # there was a problem with Python bailing out because of # http://en.wikipedia.org/wiki/Diamond_problem with interfaces, -- 2.7.4