[Python-Dev] tp_dealloc (original) (raw)
Greg Ewing greg.ewing at canterbury.ac.nz
Tue Jun 1 02:33:23 CEST 2010
- Previous message: [Python-Dev] _XOPEN_SOURCE on Solaris
- Next message: [Python-Dev] Implementing PEP 382, Namespace Packages
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
smarv at gmx.net wrote:
Now, the problem is, Python appears to read-access the deallocated memory still after tpdealloc.
It's not clear exactly what you mean by "after tp_dealloc". The usual pattern is for a type's tp_dealloc method to call the base type's tp_dealloc, which can make further references to the object's memory. At the end of the tp_dealloc chain, tp_free gets called, which is what actually deallocates the memory.
I would say your tp_dealloc shouldn't be modifying anything in the object struct that your corresponding tp_alloc method didn't set up, because code further along the tp_dealloc chain may rely on it. That includes fields in the object header.
-- Greg
- Previous message: [Python-Dev] _XOPEN_SOURCE on Solaris
- Next message: [Python-Dev] Implementing PEP 382, Namespace Packages
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]