Unicode docstrings in PyMethodDef?

Craig Ringer craig at postnewspapers.com.au
Fri Dec 10 22:23:04 CET 2004


On Wed, 2004-12-08 at 13:43, Craig Ringer wrote:
> Hi folks
> 
> I'm currently working on a fairly well internationalised app that embeds
> a Python intepreter. I'd like to make the docstrings translatable, but
> am running into the issue that the translation function returns unicode
> data.

For the use of anybody asking the same question later: There doesn't
appear to be a nice way to make docstrings unicode, or not one I could
find. I ended up just changing the sysdefaultencoding to utf-8 because
that solved a bunch of other problems in the app too. A fairly drastic
step, to be sure, but OK because it's an embedded interpreter that
doesn't have to worry about compatibility with most existing Python
scripts (except libs/modules, which should AFAIK consider not accepting
utf a bug). The change from the default Python behaviour has been
clearly documented.

In particular, now users can easily use literals in any language they
choose (except some arabit and indic languages and thai) in the embedded
Python console, and have everything work as they expect.

If this is the wrong approach, someone please yell at me - but only if
you can tell me the right one.

--
Craig Ringer




More information about the Python-list mailing list