Re: can't load plpython
От | Alvaro Herrera |
---|---|
Тема | Re: can't load plpython |
Дата | |
Msg-id | 20090403180036.GH23023@alvh.no-ip.org обсуждение исходный текст |
Ответ на | Re: can't load plpython (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: can't load plpython
|
Список | pgsql-hackers |
Tom Lane wrote: > Alvaro's example now gives me this on Fedora 10: > > ERROR: PL/Python: PL/Python function "unaccent" failed > DETAIL: <type 'exceptions.TypeError'>: normalize() argument 2 must be unicode, not str > > which is the same as it did in 8.3. I do not know if that's a bug > or expected (making the database encoding be utf8 doesn't help). Apparently the problem is that "str" is a different type in Python than "unicode". I could get it to work this way: create or replace function unaccent(text) returns text language plpythonu as $$ import unicodedata rv = plpy.execute("select setting from pg_settings where name = 'server_encoding'"); encoding = rv[0]["setting"] s = args[0].decode(encoding) s = unicodedata.normalize("NFKD", s) s = ''.join(c for c in s if ord(c) < 127) return s $$; > Alvaro, would you see if it still crashes for you on Debian? > If so there's some other issue with python 2.5.4 ... It works for me now. Thanks to Euler for tracking the Python problem down and to you for the commit! -- Alvaro Herrera http://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support
В списке pgsql-hackers по дате отправления: