Re: Problem with python compile

From: Bernhard Herzog <bh(at)intevation(dot)de>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: PostgreSQL-interfaces <pgsql-interfaces(at)postgresql(dot)org>, dwallace(at)udel(dot)edu, darcy(at)druid(dot)net
Subject: Re: Problem with python compile
Date: 2002-03-25 11:18:56
Message-ID: 6qd6xshp3z.fsf@abnoba.intevation.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)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(at)udel(dot)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/

In response to

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Jose Luis LG 2002-03-25 11:19:44 Checking if a table locked from pl/pgsql
Previous Message Bruce Momjian 2002-03-25 01:49:11 Problem with python compile