[Zope] ordinal not in range error in StringIO.py

Roman Susi rnd at onego.ru
Tue Apr 25 03:25:45 EDT 2006


hi!


My code produces the following traceback

  File "/opt/Zope-2.9.1/lib/python/ZPublisher/Publish.py", line 40, in
call_object
    result=apply(object,args) # Type s<cr> to step into published object.
  File "/var/zope-2.9/Products/Five/browser/metaconfigure.py", line 403,
in __call__
    return self.index(self, *args, **kw)
  File "/opt/Zope-2.9.1/lib/python/Shared/DC/Scripts/Bindings.py", line
311, in __call__
    return self._bindAndExec(args, kw, None)
  File "/opt/Zope-2.9.1/lib/python/Shared/DC/Scripts/Bindings.py", line
348, in _bindAndExec
    return self._exec(bound_data, args, kw)
  File
"/opt/Zope-2.9.1/lib/python/Products/PageTemplates/PageTemplateFile.py",
line 110, in _exec
    return self.pt_render(extra_context=bound_names)
  File
"/opt/Zope-2.9.1/lib/python/Products/PageTemplates/PageTemplate.py",
line 105, in pt_render
    return output.getvalue()
  File "/opt/lib/python2.4/StringIO.py", line 272, in getvalue
    self.buf += ''.join(self.buflist)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 8:
ordinal not in range(128)

when frontpage is published. I have analysed self.buflist and it seems that unicode strings are mixed with usual strings. Unicode strings come from .mo file.
So, the question is why ZPublisher doesnt coerce different string before serving and what can I do in this situation?

.po file has utf8 encoding. Publisher encoding is utf8.

Quick and very dirty solution is to mend StringIO.py... 
Does anybody has better cure? Thanks!


Regards,
Roman Suzi



More information about the Zope mailing list