[ZPT] Re: Fix for UnicodeError: ASCII decoding error: ordinal not in
range(128)
Florent Guillaume
fg@nuxeo.com
24 Jan 2003 18:00:39 +0100
But at least it's not in TranslationService anymore :-)
Really, I think we should have a specialized getvalue() in
TALInterpreter. Something along the lines of this test:
from StringIO import StringIO
from types import UnicodeType
import sys
defaultencoding = sys.getdefaultencoding()
class FasterStringIO(StringIO):
# ...
def getvalue(self):
try:
return ''.join(self.buflist)
except UnicodeError:
ul = []
for s in self.buflist:
if isinstance(s, UnicodeType):
ul.append(s)
else:
ul.append(unicode(s, defaultencoding, 'replace'))
return ''.join(ul)
a = FasterStringIO()
a.write('é')
a.write(u'é')
print `a.getvalue()`
Could you try adding that method and the necessary import into
TALInterpreter.py to diagnose the problem?
Florent
On Fri, 2003-01-24 at 17:42, vlado wrote:
> Hi,
>
> I tryed LOCALIZER_USE_ZOPE_UNICODE=1 and hitted the same UnicodeError
> again.
> I'm using z2.6.1b1, Localizer1.0, TranslationService0.2
> this is the traceback:
>
> * Module ZPublisher.Publish, line 150, in publish_module
> * Module Products.Localizer, line 55, in new_publish
> * Module ZPublisher.Publish, line 114, in publish
> * Module Zope.App.startup, line 182, in zpublisher_exception_hook
> * Module ZPublisher.Publish, line 98, in publish
> * Module ZPublisher.mapply, line 88, in mapply
> * Module ZPublisher.Publish, line 39, in call_object
> * Module Shared.DC.Scripts.Bindings, line 252, in __call__
> * Module Shared.DC.Scripts.Bindings, line 283, in _bindAndExec
> * Module Products.CMFCore.FSPageTemplate, line 189, in _exec
> * Module Products.CMFCore.FSPageTemplate, line 122, in pt_render
> * Module Products.PageTemplates.PageTemplate, line 95, in pt_render
> <FSPageTemplate at /Sites/test/login_form used for /Sites/test>
> * Module TAL.TALInterpreter, line 186, in __call__
> * Module TAL.TALInterpreter, line 230, in interpret
> * Module TAL.TALInterpreter, line 689, in do_useMacro
> * Module TAL.TALInterpreter, line 230, in interpret
> * Module TAL.TALInterpreter, line 622, in do_loop_tal
> * Module TAL.TALInterpreter, line 230, in interpret
> * Module TAL.TALInterpreter, line 400, in do_optTag_tal
> * Module TAL.TALInterpreter, line 385, in do_optTag
> * Module TAL.TALInterpreter, line 380, in no_tag
> * Module TAL.TALInterpreter, line 230, in interpret
> * Module TAL.TALInterpreter, line 655, in do_condition
> * Module TAL.TALInterpreter, line 230, in interpret
> * Module TAL.TALInterpreter, line 400, in do_optTag_tal
> * Module TAL.TALInterpreter, line 385, in do_optTag
> * Module TAL.TALInterpreter, line 380, in no_tag
> * Module TAL.TALInterpreter, line 230, in interpret
> * Module TAL.TALInterpreter, line 689, in do_useMacro
> * Module TAL.TALInterpreter, line 230, in interpret
> * Module TAL.TALInterpreter, line 745, in do_onError_tal
> * Module StringIO, line 160, in getvalue
>
> UnicodeError: ASCII decoding error: ordinal not in range(128) (Also, an
> error occurred while attempting to render the standard error message.)
--
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 87 http://nuxeo.com mailto:fg@nuxeo.com