Re: process crash when a plpython function returns
От | James William Pye |
---|---|
Тема | Re: process crash when a plpython function returns |
Дата | |
Msg-id | 1120798223.832.26.camel@localhost обсуждение исходный текст |
Ответ на | Re: process crash when a plpython function returns unicode (Michael Fuhr <mike@fuhr.org>) |
Список | 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
В списке pgsql-hackers по дате отправления: