Destructor being called twice?

Duncan Booth duncan.booth at invalid.invalid
Mon Apr 12 16:58:02 EDT 2010


Longpoke <longpoke at gmail.com> wrote:

> So either this test case is wrong to assume the destructor can only be
> called once, or there is a bug in Python?

Or perhaps more likely you misunderstand what is happening here. Maybe 
there are two separate instances of A()?

If I remember correctly gtk wraps C objects in Python wrappers when they 
are accessed from Python code. A python wrapper isn't created until it is 
needed and it is destroyed as soon as it is no longer needed.

Since don't save a Python reference to your A() instance when you create 
it I'd expect the original wrapper is destroyed and the another one created 
later when needed. The test does hang on to the gobj reference so there's 
only going to be a single wrapper.



More information about the Python-list mailing list