Imported Upstream version 3.0.1 42/138242/1
authorDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 11 Jul 2017 23:37:54 +0000 (08:37 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 11 Jul 2017 23:37:56 +0000 (08:37 +0900)
Change-Id: I26a0bcadb4a71ef2c031860ee9d617b250d3a6d7
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
ChangeLog
NEWS
PKG-INFO
configure
configure.ac
gi/_gobject/gobjectmodule.c
gi/_gobject/pygobject-private.h
gi/_gobject/pygobject.c
gi/_gobject/pygobject.h
gi/pygi-marshal-from-py.c

index d307ea45d810c7a77d840f86bb710ec43696f23e..9bd04d34158ee42ff604c3fd86c247cc73f2672f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,57 @@
+commit 56ac9339eb1d6950623dc4d8c3b9972874e7fa86
+Author: John (J5) Palmieri <johnp@redhat.com>
+Date:   Thu Sep 22 19:03:20 2011 -0400
+
+    when checking instances union members are same type as parent
+
+    * this is so we can support sending Gdk.Event members in place of
+      the Event union into methods
+    * we only support this if the union member has a type of GI_INTERFACE
+    for now
+
+    https://bugzilla.gnome.org/show_bug.cgi?id=659879
+
+ gi/pygi-marshal-from-py.c |   60
+ ++++++++++++++++++++++++++++++++++++++++++---
+ 1 files changed, 56 insertions(+), 4 deletions(-)
+
+commit 311a4f8035a95b41bc3c0a836c32b7a5bf2d9959
+Author: John (J5) Palmieri <johnp@redhat.com>
+Date:   Wed Sep 21 21:50:48 2011 -0400
+
+    add a floating flag to pygobjects
+
+    * this allows us to correctly refcount when custom gobjects are
+    instantiated
+      via g_object_new
+
+ gi/_gobject/gobjectmodule.c     |    5 +++++
+ gi/_gobject/pygobject-private.h |    3 +++
+ gi/_gobject/pygobject.c         |   27 ++++++++++++++++++++++++++-
+ gi/_gobject/pygobject.h         |    3 ++-
+ 4 files changed, 36 insertions(+), 2 deletions(-)
+
+commit d2d29ae5845217254b9336fd8629f369cb119b25
+Author: John (J5) Palmieri <johnp@redhat.com>
+Date:   Wed Sep 21 21:13:22 2011 -0400
+
+    Revert "Fix refcount bug by not creating python wrapper during
+    gobject init stage"
+
+    This reverts commit f6fa5dd8f39af1b8a52d7600d257400b0983e8c5.
+
+ gi/_gobject/gobjectmodule.c |   32 +++++++++++++++++---------------
+ 1 files changed, 17 insertions(+), 15 deletions(-)
+
+commit a24c10b779f2a1b0425d56d03d59c393389cad98
+Author: John (J5) Palmieri <johnp@redhat.com>
+Date:   Wed Sep 21 21:10:00 2011 -0400
+
+    make sure to commit the NEWS file
+
+ NEWS |    4 ++++
+ 1 files changed, 4 insertions(+), 0 deletions(-)
+
 commit 2eed2940c9be099fb6305288d895265e6b35d3d2
 Author: John (J5) Palmieri <johnp@redhat.com>
 Date:   Mon Sep 19 13:19:57 2011 -0400
diff --git a/NEWS b/NEWS
index 2a8cf082e3ad59c323ea4152200ce7556ded2849..d3792f1f614214b105e57d3f7d6847ba05f2a6e9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,8 @@
+3.0.1   30-Sep-2011
+       - when checking instances union members are same type as parent
+       - add a floating flag to pygobjects
+       - Revert "Fix refcount bug by not creating python wrapper during gobject init stage"
+
 3.0.0   19-Sep-2011
         - up version required of gobject-introspection to 1.29.0 (John (J5) Palmieri)
         - fix most warnings (John (J5) Palmieri)
index 4b92ae8cd2496a007107b8766acf61afa85d089e..4c1a946d31c7488da48bacfa1a2fcea60c24257b 100644 (file)
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: PyGObject
-Version: 3.0.0
+Version: 3.0.1
 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.0/pygobject-3.0.0.tar.gz
+Download-url: ftp://ftp.gnome.org/pub/GNOME/sources/pygobject/3.0/pygobject-3.0.1.tar.gz
 Description: Python bindings for GLib and GObject
 Platform: POSIX, Windows
 Classifier: Development Status :: 5 - Production/Stable
index c09caabce8efbc5170f41fa54ebe3d31cd7175bd..57590f53ec345ad4cf7745c3dd666e312c54c078 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68 for pygobject 3.0.0.
+# Generated by GNU Autoconf 2.68 for pygobject 3.0.1.
 #
 # Report bugs to <http://bugzilla.gnome.org/enter_bug.cgi?product=pygobject>.
 #
@@ -571,8 +571,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='pygobject'
 PACKAGE_TARNAME='pygobject'
-PACKAGE_VERSION='3.0.0'
-PACKAGE_STRING='pygobject 3.0.0'
+PACKAGE_VERSION='3.0.1'
+PACKAGE_STRING='pygobject 3.0.1'
 PACKAGE_BUGREPORT='http://bugzilla.gnome.org/enter_bug.cgi?product=pygobject'
 PACKAGE_URL=''
 
@@ -1358,7 +1358,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.0.0 to adapt to many kinds of systems.
+\`configure' configures pygobject 3.0.1 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1428,7 +1428,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of pygobject 3.0.0:";;
+     short | recursive ) echo "Configuration of pygobject 3.0.1:";;
    esac
   cat <<\_ACEOF
 
@@ -1553,7 +1553,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-pygobject configure 3.0.0
+pygobject configure 3.0.1
 generated by GNU Autoconf 2.68
 
 Copyright (C) 2010 Free Software Foundation, Inc.
@@ -1831,7 +1831,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.0.0, which was
+It was created by pygobject $as_me 3.0.1, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   $ $0 $@
@@ -2195,9 +2195,9 @@ $as_echo "#define PYGOBJECT_MINOR_VERSION 0" >>confdefs.h
 PYGOBJECT_MINOR_VERSION=0
 
 
-$as_echo "#define PYGOBJECT_MICRO_VERSION 0" >>confdefs.h
+$as_echo "#define PYGOBJECT_MICRO_VERSION 1" >>confdefs.h
 
-PYGOBJECT_MICRO_VERSION=0
+PYGOBJECT_MICRO_VERSION=1
 
 
 ac_config_headers="$ac_config_headers config.h"
@@ -2681,7 +2681,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='pygobject'
- VERSION='3.0.0'
+ VERSION='3.0.1'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -12017,7 +12017,7 @@ Usage: $0 [OPTIONS]
 Report bugs to <bug-libtool@gnu.org>."
 
 lt_cl_version="\
-pygobject config.lt 3.0.0
+pygobject config.lt 3.0.1
 configured by $0, generated by GNU Autoconf 2.68.
 
 Copyright (C) 2010 Free Software Foundation, Inc.
@@ -16723,7 +16723,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.0.0, which was
+This file was extended by pygobject $as_me 3.0.1, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -16789,7 +16789,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.0.0
+pygobject config.status 3.0.1
 configured by $0, generated by GNU Autoconf 2.68,
   with options \\"\$ac_cs_config\\"
 
index 8946b85db486d050a6c56507dd75887dc69de3c7..937c13f60d920368f4716af8fa338277aac9e166 100644 (file)
@@ -12,7 +12,7 @@ m4_define(python3_min_ver, 3.1)
 dnl the pygobject version number
 m4_define(pygobject_major_version, 3)
 m4_define(pygobject_minor_version, 0)
-m4_define(pygobject_micro_version, 0)
+m4_define(pygobject_micro_version, 1)
 m4_define(pygobject_version, pygobject_major_version.pygobject_minor_version.pygobject_micro_version)
 
 dnl versions of packages we require ...
index ffa323b2a61b1fe90b51eb1dadb8ecc22a3f7ccb..ac065a5e65efebce7f5c732ff0724e3d5b746f47 100644 (file)
@@ -1048,7 +1048,7 @@ pygobject__g_instance_init(GTypeInstance   *instance,
                            gpointer         g_class)
 {
     GObject *object = (GObject *) instance;
-    PyObject *wrapper;
+    PyObject *wrapper, *args, *kwargs;
 
     wrapper = g_object_get_qdata(object, pygobject_wrapper_key);
     if (wrapper == NULL) {
@@ -1059,6 +1059,27 @@ pygobject__g_instance_init(GTypeInstance   *instance,
         }
     }
     pygobject_init_wrapper_set(NULL);
+    if (wrapper == NULL) {
+          /* this looks like a python object created through
+           * g_object_new -> we have no python wrapper, so create it
+           * now */
+        PyGILState_STATE state;
+        state = pyglib_gil_state_ensure();
+        wrapper = pygobject_new_full(object, FALSE, g_class);
+
+        /* float the wrapper ref here because we are going to orphan it
+         * so we don't destroy the wrapper. The next call to pygobject_new_full
+         * will take the ref */
+        pygobject_ref_float (wrapper);
+        args = PyTuple_New(0);
+        kwargs = PyDict_New();
+        if (Py_TYPE(wrapper)->tp_init(wrapper, args, kwargs))
+            PyErr_Print();
+
+        Py_DECREF(args);
+        Py_DECREF(kwargs);
+        pyglib_gil_state_release(state);
+    }
 }
 
 
@@ -1730,22 +1751,8 @@ pyg_object_new (PyGObject *self, PyObject *args, PyObject *kwargs)
     g_type_class_unref(class);
 
     if (obj) {
-        PyObject *empty_args;
-        PyObject *empty_kwargs;
-        PyGILState_STATE state;
-
         pygobject_sink (obj);
        self = (PyGObject *) pygobject_new_full((GObject *)obj, FALSE, NULL);
-        empty_args = PyTuple_New(0);
-        empty_kwargs = PyDict_New();
-
-        state = pyglib_gil_state_ensure();
-        if (Py_TYPE(self)->tp_init((PyObject *)self, empty_args, empty_kwargs))
-            PyErr_Print();
-        pyglib_gil_state_release(state);
-
-        Py_DECREF(empty_args);
-        Py_DECREF(empty_kwargs);
         g_object_unref(obj);
     } else
         self = NULL;
index dabf0a4e596e72174ba092c27f6f3041eac24753..1b1d6db65b0f593589c654ae646db1ea6634de3c 100644 (file)
@@ -96,6 +96,9 @@ PyObject *pyg_integer_richcompare(PyObject *v,
 
 gboolean pyg_gerror_exception_check(GError **error);
 
+void pygobject_ref_float(PyGObject *self);
+void pygobject_ref_sink(PyGObject *self);
+
 /* from pygtype.h */
 extern PyTypeObject PyGTypeWrapper_Type;
 
index 48a9f1885298b0bc76fef87a48cb6c218297fe16..0f0e5e2171f3530cd453b66eba7160ebcfcc26df 100644 (file)
@@ -560,6 +560,31 @@ pygobject_switch_to_toggle_ref(PyGObject *self)
     g_object_unref(self->obj);
 }
 
+/* Called when an custom gobject is initalized via g_object_new instead of
+   its constructor.  The next time the wrapper is access via 
+   pygobject_new_full it will sink the floating reference instead of
+   adding a new reference and causing a leak */
+void
+pygobject_ref_float(PyGObject *self)
+{
+    /* should only be floated once */
+    g_assert(!(self->private_flags.flags & PYGOBJECT_IS_FLOATING_REF));
+    
+    self->private_flags.flags |= PYGOBJECT_IS_FLOATING_REF;
+}
+
+/* Called by gobject_new_full, if the floating flag is set remove it, otherwise
+   ref the pyobject */
+void
+pygobject_ref_sink(PyGObject *self)
+{
+    if (self->private_flags.flags & PYGOBJECT_IS_FLOATING_REF)
+        self->private_flags.flags &= ~PYGOBJECT_IS_FLOATING_REF;
+    else
+        Py_INCREF ( (PyObject *) self);
+}
+
 /**
  * pygobject_register_wrapper:
  * @self: the wrapper instance
@@ -888,7 +913,7 @@ pygobject_new_full(GObject *obj, gboolean sink, gpointer g_class)
     /* we already have a wrapper for this object -- return it. */
     self = (PyGObject *)g_object_get_qdata(obj, pygobject_wrapper_key);
     if (self != NULL) {
-       Py_INCREF(self);
+       pygobject_ref_sink(self);
     } else {
        /* create wrapper */
         PyGObjectData *inst_data = pyg_object_peek_inst_data(obj);
index f728e1573a4df39443f78f0f8f1618ecc92027ca..8879fd0791f2af3215f61681c844bb37dddd3bb5 100644 (file)
@@ -23,7 +23,8 @@ struct _PyGClosure {
 };
 
 typedef enum {
-    PYGOBJECT_USING_TOGGLE_REF = 1 << 0
+    PYGOBJECT_USING_TOGGLE_REF = 1 << 0,
+    PYGOBJECT_IS_FLOATING_REF = 1 << 1
 } PyGObjectFlags;
 
   /* closures is just an alias for what is found in the
index fa74a22904df1d04bfc3ce79be2d694216c03c13..b78cfe3f04f807131f93fd7d1dc0bcefa1abb7da 100644 (file)
@@ -1416,10 +1416,62 @@ gboolean _pygi_marshal_from_py_interface_instance (PyGIInvokeState   *state,
             GType type = iface_cache->g_type;
 
             if (!PyObject_IsInstance (py_arg, iface_cache->py_type)) {
-                PyErr_Format (PyExc_TypeError, "Expected a %s, but got %s",
-                              iface_cache->type_name,
-                              py_arg->ob_type->tp_name);
-                return FALSE;
+                /* wait, we might be a member of a union so manually check */
+                if (info_type == GI_INFO_TYPE_UNION) {
+                    gint i;
+                    gint n_fields;
+                    gboolean is_member = FALSE;
+                    GIUnionInfo *union_info = (GIUnionInfo *) iface_cache->interface_info;
+
+                    n_fields = g_union_info_get_n_fields (union_info);
+
+                    for (i = 0; i < n_fields; i++) {
+                        GIFieldInfo *field_info;
+                        GITypeInfo *field_type_info;
+
+                        field_info = g_union_info_get_field (union_info, i);
+                        field_type_info = g_field_info_get_type (field_info);
+
+                        /* we can only check if the members are interfaces */
+                        if (g_type_info_get_tag (field_type_info) ==
+                            GI_TYPE_TAG_INTERFACE) {
+                            PyObject *py_type;
+                            GIInterfaceInfo *field_iface_info =
+                                g_type_info_get_interface(field_type_info);
+
+                            py_type = _pygi_type_import_by_gi_info (
+                                (GIBaseInfo *) field_iface_info);
+
+                            if (PyObject_IsInstance (py_arg, py_type)) {
+                                is_member = TRUE;
+                                break;
+                            }
+
+                            Py_XDECREF (py_type);
+                            g_base_info_unref ( ( GIBaseInfo *) field_iface_info);
+
+                        }
+
+                        g_base_info_unref ( ( GIBaseInfo *) field_type_info);
+                        g_base_info_unref ( ( GIBaseInfo *) field_info);
+
+                        if (is_member)
+                            break;
+                    }
+
+                    if (!is_member) {
+                        PyErr_Format (PyExc_TypeError,
+                                      "Expected a %s, but got %s",
+                                      iface_cache->type_name,
+                                      py_arg->ob_type->tp_name);
+                        return FALSE;
+                    }
+                } else {
+                    PyErr_Format (PyExc_TypeError, "Expected a %s, but got %s",
+                                  iface_cache->type_name,
+                                  py_arg->ob_type->tp_name);
+                    return FALSE;
+                }
             }
 
             if (g_type_is_a (type, G_TYPE_BOXED)) {