">

(original) (raw)

 

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, PyObject\_Free() will default to free() for objects that it doesn’t recognize, so this works.� But is this documented behavior?� The reason I ran into this was that I had redirect the PyMem\_\* API to a different allocator, but left the PyObject\_\* one alone.

 

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.

 

Any thoughts?

 

Kristj�n