Re: process crash when a plpython function returns

From: James William Pye <pgsql(at)jwp(dot)name>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org, Tino Wildenhain <tino(at)wildenhain(dot)de>
Subject: Re: process crash when a plpython function returns
Date: 2005-07-08 04:50:23
Message-ID: 1120798223.832.26.camel@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Mon, 2005-06-27 at 08:12 -0600, Michael Fuhr wrote:
> > also in this context it would be helpful
> > if sys.defaultencoding would be set to
> > the database encoding so strings get encoded
> > to utf-8 when postgres works in unicode mode
> > rather then the default encoding of ascii.
> > This could avoid most of the PyObject_Str()
> > exeptions in the first place.
>
> I haven't looked at doing that yet and probably won't before feature
> freeze. Gerrit van Dyk has expressed an interest in hacking on
> PL/Python (he recently submitted a SETOF patch) so maybe he'll work
> on it.

I have this fixed, for the most part, in PL/Py. What I have done might
be a good starting place for someone who wants to get it fixed in core.

http://cvs.pgfoundry.org/cgi-bin/cvsweb.cgi/python/be/src/encoding.c

This file makes using PostgreSQL encodings in Python a more friendly
experience by setting up some aliases. (u"óäæ".encode('UNICODE') would
work in 8.0)

Also, to set the default encoding used by Python's Unicode strings:
PyUnicode_SetDefaultEncoding(PyEncoding_FromPgEncoding(GetDatabaseEncoding()))

PyEncoding_FromPgEncoding is defined in encoding.c.

Also, it should be noted that to get the interpreter to read the
function code as a specific encoding, one must use, afaik, the # -*-
encoding: utf-8 -*- magic.
--
Regards, James William Pye

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Volkan YAZICI 2005-07-08 06:35:30 Re: BUG #1756: PQexec eats huge amounts of memory
Previous Message Tom Lane 2005-07-07 20:52:19 Re: BUG #1757: timestamp 'epoch' is not absolute

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2005-07-08 04:53:14 Re: User's exception plpgsql
Previous Message Neil Conway 2005-07-08 04:49:58 Re: User's exception plpgsql