Re: Problem with python compile - Mailing list pgsql-interfaces

From Bernhard Herzog
Subject Re: Problem with python compile
Date
Msg-id 6qd6xshp3z.fsf@abnoba.intevation.de
Whole thread Raw
In response to Problem with python compile  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: Problem with python compile
List pgsql-interfaces
Bruce Momjian <pgman@candle.pha.pa.us> writes:

> PyGreSQL causes a segfault when used with a Python executable that was
> compiled with --with-pymalloc.  This change fixes that.  Thanks to
> Dave Wallace <dwallace@udel.edu>
> 
> ---------------------------------------------------------------------------
> 
> The patch changes PyMem_DEL(self) to PyObject_DEL(self).
> 
> This is with python 1.5.  I suggest that we should reverse out this patch.
> The fix for --with-pymalloc clearly is causing problems for regular
> compiles.

This depends on the Python version. PyObject_DEL (which really should be
PyObject_Del, i.e. the function not the macro) is not defined in 1.5 but
it's defined in 2.x and the proper way to free memory allocated with
PyObject_New. In 1.5 PyMem_Del is OK. 

If you want compatibility from 1.5.2 up to 2.2 with pymalloc something
like this should work, I think:

#if PY_VERSION_HEX < 0x01060000
#define PyObject_Del(op) PyMem_Del((op))
#endif

This is basically what is done in Python's _sre.c.

Python's memory management API (which is a bit of a mess) and pymalloc
is currently a very actively discussed topic on python-dev.

  Bernhard

-- 
Intevation GmbH                                 http://intevation.de/
Sketch                                 http://sketch.sourceforge.net/
MapIt!                                           http://www.mapit.de/


pgsql-interfaces by date:

Previous
From: "Jose Luis LG"
Date:
Subject: Checking if a table locked from pl/pgsql
Next
From: "D'Arcy J.M. Cain"
Date:
Subject: Re: Problem with python compile