[Python-Dev] PyMem_Malloc() vs PyObject_Malloc()

2009-09-04 Thread Kristján Valur Jónsson
I noticed something (in 2.5) yesterday, which may be a feature, but is more likely a bug. In tokenizer.c, tok-encoding is allocated using PyMem_MALLOC(). However, this then gets handed to a node-r_str in parsetok.c, and then released in node.c using PyObject_Free(). Now, by coincidence,

Re: [Python-Dev] PyMem_Malloc() vs PyObject_Malloc()

2009-09-04 Thread M.-A. Lemburg
Kristján Valur Jónsson wrote: I noticed something (in 2.5) yesterday, which may be a feature, but is more likely a bug. In tokenizer.c, tok-encoding is allocated using PyMem_MALLOC(). However, this then gets handed to a node-r_str in parsetok.c, and then released in node.c using

Re: [Python-Dev] PyMem_Malloc() vs PyObject_Malloc()

2009-09-04 Thread Nick Coghlan
Kristján Valur Jónsson wrote: My feeling Is that these two APIs shouldn’t be interchangeable. Especially since you can’t hand a PyObject_Malloc’d object to PyMem_Free() so the inverse shouldn’t be expected to work. I thought this had officially been deemed illegal for a while, and Google