[mod_python] Unicode support?

Mateusz Korniak mateusz at ant.gliwice.pl
Thu Jun 24 05:09:28 EDT 2004


Jon-Pierre Gentil wrote:

>=============
>Mod_python error: "PythonHandler mod_python.publisher"
>
>Traceback (most recent call last):
>
>  File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line
>299, in HandlerDispatch
>    result = object(req)
>
>  File "/usr/lib/python2.3/site-packages/mod_python/publisher.py", line
>143, in handler
>    result = str(result)
>
>UnicodeEncodeError: 'ascii' codec can't encode characters in position
>2144-2145: ordinal not in range(128)
>==============
>
>Why does it re-encode it?
>  
>
I assume result is unicode string, so str() tries to convert it to local 
representation, which may be 'ascii' for mod_python.

Try:
result = result.encode("utf-8")

Mateusz Korniak




More information about the Mod_python mailing list