[Python-Dev] pdb segfaults in 2.5 trunk?

Guido van Rossum guido at python.org
Tue Apr 11 00:06:52 CEST 2006


On 4/10/06, Tim Peters <tim.peters at gmail.com> wrote:
> It's documented (after a fashion) at the declaration of
> PyOS_ReadlineFunctionPointer.  Yesterday that read:
>
> """
> /* By initializing this function pointer, systems embedding Python can
>    override the readline function.
>
>    Note: Python expects in return a buffer allocated with PyMem_Malloc. */
>
> char *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *);
> """
>
> Overnight, "PyMem_Malloc" there changed to "PyObject_Malloc".  It
> didn't matter in practice before (2.5) because all PyXYZ_ABC ways to
> spell "free the memory" resolved to PyObject_Free.  Now that PyMem_
> and PyObject_ call different things, mismatches  are deadly.  Since
> the only docs we had said PyMem_Malloc must be used for the readline
> function, best to stick with that.  It's messy, though (there are a
> lot of functions that think they're in charge of freeing the memory,
> and the memory can originally come from a lot of places).

Shouldn't it at least match call_readline() in Modules/readline.c,
which uses PyMem_Malloc()? Also, since it's really a char array, I
don't see the point of using something with "Object" in its name.

--
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list