[pygtk] PyGTK object escapes garbage collection
gerald.britton at gmail.com
Fri Dec 24 21:17:59 WST 2010
On Fri, Dec 24, 2010 at 5:28 AM, Hrvoje Niksic <hrvoje.niksic at avl.com> wrote:
> The problem you describe sounds like it might be related to this infamous
> PyGTK bug:
> In our tests the problems show up when a Python object that participates in
> a cycle is referenced only through a GTK widget. When GC takes place,
> Python's cycle-breaker incorrectly concludes that the whole cycle is
> unreachable and runs tp_clear on all objects. The objects are, of course,
> still reachable through PyGTK, and unfortunately now quite broken.
> A number of workarounds are available: simply access the widget's __dict__,
> which forces it to switch to a different reference-counting strategy. Or
> store a reference to your object in a global variable or container.
To me, this is clearly a pygtk bug. It should not be creating cycles
like this. Also, it can create cycles without your participation. If
you use builder, it can find callbacks using introspection. I have
some modules that use introspection and have a few "connect" calls as
well. To have to do all the introspection yourself in your own
modules is ridiculous.
> pygtk mailing list pygtk at daa.com.au
> Read the PyGTK FAQ: http://faq.pygtk.org/
More information about the pygtk