[mod_python] unicode() conversion troubles with mod_python 3 CVS 27.06.2002

Martin Pool mbp at samba.org
Tue Nov 19 16:36:58 EST 2002


On 24 Oct 2002, Eugene Sizikov <eugene_beast at mail.ru> wrote:
> Hello all ppl!
> 
> I have troubles with unicode conversion with mod_python from RedHat 8.0
> distro. The errorlog is:
> 
> "
> Mod_python error: "PythonHandler mod_python.publisher"
> 
> Traceback (most recent call last):
> 
>   File "/usr/lib/python2.2/site-packages/mod_python/apache.py", line 285, in
> HandlerDispatch
>     result = object(req)
> 
>   File "/usr/lib/python2.2/site-packages/mod_python/publisher.py", line 175,
> in handler
>     result = apply(object, (), args)
> 
>   File "/var/www/html/teleross/user.py", line 137, in start
>     html = '%s [%s]<HR>' % (string_sql_to_html(user.fullname),
> Group(user.con, user.gid).fullname) + menu.to_html()
> 
>   File "/var/www/html/teleross/utils.py", line 4, in string_sql_to_html
>     return unicode(s, 'koi8-r')
> 
>   File
> "/usr/src/build/143041-i386/install/usr/lib/python2.2/encodings/__init__.py"
> , line 51, in search_function
> 
> RuntimeError: cannot unmarshal code objects in restricted execution mode
> "
> 
> So, when it has "unicode(s, 'koi8-r')" it crashes with that interesting
> message I can't understand.

I had a similar problem.  It seemed to me to be some kind of
interaction between encoders being imported by the C encode()
implementation and modules being imported by mod_python.
Unfortunately I could only look at it without our complicated build
environment so I can't say for sure.

A workaround turned out to be forcing the encoders to be loaded before
mod_python starts up.  You can do this by adding a line like this to
sitecustom.py:

  u'hello'.encode('koi8-r')

-- 
Martin



More information about the Mod_python mailing list