After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 638267 - gc.collect deletes __dict__ of an object in a GTK-object, Python-object cycle
gc.collect deletes __dict__ of an object in a GTK-object, Python-object cycle
Status: RESOLVED DUPLICATE of bug 731501
Product: pygobject
Classification: Bindings
Component: gobject
3.2.x
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks: 693111
 
 
Reported: 2010-12-29 13:27 UTC by Michael Kainer
Modified: 2017-10-27 19:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Example that shows the bug. (644 bytes, text/plain)
2010-12-29 13:27 UTC, Michael Kainer
Details

Description Michael Kainer 2010-12-29 13:27:18 UTC
Created attachment 177189 [details]
Example that shows the bug.

Linux fortuna 2.6.37-11-generic #25-Ubuntu SMP Tue Dec 21 23:42:56 UTC 2010 x86_64 GNU/Linux
Python 2.7.1+
python-gobject 2.27.0-0ubuntu5
python-gtk2 2.22.0-0ubuntu1


First we need a class that contains some GTK+ widgets and a signal connected. I'll take this simple class:

class SomeWindow(object):

    def __init__(self):
        self.button = gtk.Button("Click me")
        self.button.connect("clicked", self._on_button_clicked)
        
        self.window = gtk.Window()
        self.window.add(self.button)

        print self.__dict__
    
    def show(self):
        self.window.show_all()
    
    def _on_button_clicked(self, *_):
        print self.__dict__

When I create and show the window with `SomeWindow().show()' the window is shown correctly but in the _on_button_clicked method __dict__ is {} (after the garbage collector has been invoked).

You'll find this example attached in the cycle_bug.py file.

There were some bugs like this in the past, especially
* http://www.daa.com.au/pipermail/pygtk/2008-August/015770.html and
* https://bugzilla.gnome.org/show_bug.cgi?id=92955
is very similar to this one.
Comment 1 Martin Pitt 2012-04-22 14:32:45 UTC
Confirming with 3.2.0.
Comment 2 Christoph Reiter (lazka) 2017-10-27 19:27:20 UTC
Turns out this had the same cause as bug 731501.

Fixed in 3.26.1

*** This bug has been marked as a duplicate of bug 731501 ***