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 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers