Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #743 (closed defect: fixed)

Opened 11 years ago

Last modified 10 years ago

kid default utf-8 support is incomplete

Reported by: jtate@… Owned by: anonymous
Priority: normal Milestone:
Component: Kid Version: 0.9a4
Severity: normal Keywords:
Cc:

Description

A traceback occurs if you pass non-ascii characters to kid because the templates' assume_encoding defaults to ascii and there is no way to override.

I will attach a patch to fix this issue. I hope it can make it in before 0.9.

The following is the traceback that I get:

Traceback (most recent call last):
  File "/home/jtate/devel/turbogears/thirdparty/cherrypy/cherrypy/_cphttptools.py", line 106, in _run
    self.main()
  File "/home/jtate/devel/turbogears/thirdparty/cherrypy/cherrypy/_cphttptools.py", line 255, in main
    body = page_handler(*virtual_path, **self.params)
  File "<string>", line 3, in index
  File "/home/jtate/devel/turbogears/turbogears/controllers.py", line 206, in expose
    output = database.run_with_transaction(expose._expose,func, accept, allow_json, allow_json_from_config,*args, **kw)
  File "/home/jtate/devel/turbogears/turbogears/database.py", line 216, in run_with_transaction
    retval = func(*args, **kw)
  File "<string>", line 5, in _expose
  File "/home/jtate/devel/turbogears/turbogears/controllers.py", line 227, in <lambda>
    expose._expose.when(rule)(lambda _func, accept, allow_json, allow_json_from_config,*args,**kw: _execute_func(
  File "/home/jtate/devel/turbogears/turbogears/controllers.py", line 258, in _execute_func
    return _process_output(output, template, format, content_type, mapping, fragment)
  File "/home/jtate/devel/turbogears/turbogears/controllers.py", line 56, in _process_output
    mapping=mapping, content_type=content_type,fragment=fragment)
  File "/home/jtate/devel/turbogears/turbogears/view/base.py", line 131, in render
    return engine.render(**kw)
  File "/home/jtate/devel/turbogears/plugins/kid/turbokid/kidsupport.py", line 157, in render
    return t.serialize(encoding=self.defaultencoding, output=format, fragment=fragment)
  File "/home/jtate/devel/turbogears/thirdparty/kid/kid/__init__.py", line 236, in serialize
    return serializer.serialize(self, encoding, fragment)
  File "/home/jtate/devel/turbogears/thirdparty/kid/kid/serialization.py", line 51, in serialize
    text = list(self.generate(stream, encoding, fragment))
  File "/home/jtate/devel/turbogears/thirdparty/kid/kid/serialization.py", line 327, in generate
    for ev, item in self.apply_filters(stream):
  File "/home/jtate/devel/turbogears/thirdparty/kid/kid/serialization.py", line 84, in balancing_filter
    for ev, item in stream:
  File "/home/jtate/devel/turbogears/thirdparty/kid/kid/pull.py", line 206, in _coalesce
    for ev, item in stream:
  File "/home/jtate/devel/turbogears/thirdparty/kid/kid/filter.py", line 21, in transform_filter
    for ev, item in apply_matches(stream, template, templates, apply_func):
  File "/home/jtate/devel/turbogears/thirdparty/kid/kid/filter.py", line 31, in apply_matches
    item = stream.expand()
  File "/home/jtate/devel/turbogears/thirdparty/kid/kid/pull.py", line 95, in expand
    for ev, item in self._iter:
  File "/home/jtate/devel/turbogears/thirdparty/kid/kid/pull.py", line 164, in _track
    for p in stream:
  File "/home/jtate/devel/turbogears/thirdparty/kid/kid/pull.py", line 206, in _coalesce
    for ev, item in stream:
  File "/home/jtate/test/tg/foo2/foo2/templates/index.py", line 104, in _pull
  File "/home/jtate/devel/turbogears/thirdparty/kid/kid/template_util.py", line 60, in make_attrib
    ls = [to_unicode(i, encoding) for i in v if i is not None]
  File "/home/jtate/devel/turbogears/thirdparty/kid/kid/pull.py", line 190, in to_unicode
    return unicode(value, encoding)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128)

Attachments

kid.assume_encoding.patch Download (1.9 KB) - added by jtate@… 11 years ago.
Patch to fix assume_encoding for kid output.

Change History

Changed 11 years ago by jtate@…

Patch to fix assume_encoding for kid output.

comment:1 Changed 11 years ago by anonymous

  • Component changed from CherryPy to Kid

Fix component.

comment:2 Changed 11 years ago by max

  • Status changed from new to closed
  • Resolution set to fixed

Applied in r1123.

Note: See TracTickets for help on using tickets.