Re: process crash when a plpython function returns unicode

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Tino Wildenhain <tino(at)wildenhain(dot)de>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: process crash when a plpython function returns unicode
Date: 2005-06-27 14:12:04
Message-ID: 20050627141204.GA94894@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Sat, Jun 18, 2005 at 05:27:28PM +0200, Tino Wildenhain wrote:
> Am Samstag, den 18.06.2005, 08:41 -0600 schrieb Michael Fuhr:
> >
> > I was going to submit a patch, but I don't know enough about the
> > Python API or how Python and PostgreSQL handle Unicode to know
> > whether adding that simple check is the appropriate solution (I was
> > planning to raise an error if PyObject_Str() returned NULL). Can
> > anybody think of a better fix?
>
> raise error would be a correct solution since this is what
> python does in this case:

I just submitted a patch that checks for NULL and raises an error
via PLy_elog().

> 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.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Stephan Szabo 2005-06-27 14:52:45 Re: Relational operators
Previous Message Pieter-Jan Savat 2005-06-27 10:38:51 Relational operators

Browse pgsql-hackers by date

  From Date Subject
Next Message strk 2005-06-27 14:37:11 Re: accessing postgres conf from stored procedure
Previous Message Tom Lane 2005-06-27 14:02:26 Re: contrib/rtree_gist into core system?