Python mem leaks?

tomas.bouda at systinet.com tomas.bouda at systinet.com
Wed Dec 3 07:32:03 EST 2003


  Hi,
I'm facing a problem which seems to be a Python bug... 

I've got an application written in C and having Python embedded inside.
The situation is the following:
1) C object is wrapped by PyCObject and put into Python function
2) The PyCObject has given a finalizer which frees the C object inside
3) The Python function "do_smth(panel)" is called from C 

Having the two methods: 

def do_smth1(panel):
   pass 

def do_smth2(panel):
   raise Exception() 

Calling do_smth1() will cause returning of Py_None, the PyCObject <panel> is 
freed and the C finalizer (mentioned in no.2) is called.
Calling do_smth2() will case returning NULL a <panel> is not freed nor 
finalizer is called. At this point I get a leak! 

Is it my fault? I didn't find anywhere in Python doc what should C app to do 
if such memory isn't freed. Seems more likely to be the Python leaking bug! 

Any comments or proposals? 

Thanks a lot, Tobbi 







More information about the Python-list mailing list