Re: Code freeze break request for some regressions in PyGObject

Yes, we have refcount checks for the first two which is really just a
revert of a previous patch which worked with but didn't if
it was called from C as g_object_new.  The patch is needed to avoid a
leak due to interactions between C and Python that are a bit disjoint
when using g_object_new instead of the normal constructor e.g. vs Gtk.Button() since in the Gtk.Button case
the wrapper is created and returned to python immediately where as in
the case the python wrapper is created during GObject
initialization so init can be called and then grabbed and refed once
g_object_new is finished and then returned to python.  The leak was
caused by a previous patch which removed a Py_DECREF during the
initialization stage which would cause crashes because it would
destroy the wrapper before the object was fully returned to the
calling program.  What this does is add a flag to say if you ref this
wrapper again you will have an extra ref so just take ownership of it
instead and remove the flag.  This allows us to create the wrapper
inside of the initializer and call the python init at the right spot.

The last patch is a fix of a regression from 2.28.  Python 3 does not
check instance types so the test suite was throwing asserts when an
object of the wrong type was being sent in as the first value.  Python
2 does do the instance check.  A previous patch fixed that but I
missed the edge case of unions.  Specifically Gdk.Event.  In order to
avoid crashes and issues we try to send the actual Gdk.Event union
member, e.g. Gdk.KeyEvent.  Unfortunately unions are treated like
structs so the member wrappers don't inherit from the parent union's
type and simple check is not possible to allow the members to be
passed as the union.  The fix is to iterate through all the members
and check the type of the parameter with the type of the member.
Since unions and their members are the same pointer this is a valid
way of passing it.  We need to just make sure it isn't another union's
member being passed.

On Thu, Sep 22, 2011 at 8:26 PM, Matthias Clasen
<matthias clasen gmail com> wrote:
> On Thu, Sep 22, 2011 at 7:48 PM, john palmieri
> <john j5 palmieri gmail com> wrote:
>> Hi all,
>> libpeas had some interesting regression that only happened with their
>> use of g_object_new to instantiate PyGObject objects as well as a
>> regression with the handling of unions.  The patches are here -
>> .  I'll have nacho
>> confirm that they work for him.  Without these patches and a new
>> tarball GEdit and Totem will be unable to load Python plugins.
>> Thanks.
> These look fairly scary to me. Is there any testcase coverage for
> these changes ?

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]