[Python-apps-team] Bug#690033: trac: Cannot render old ticket

Tommi Vainikainen tvainika at debian.org
Tue Oct 9 08:59:58 UTC 2012


Package: trac
Version: 0.12.2-1~bpo60+1
Severity: normal
Tags: patch

trac from backports has incompatibility with genshi version that causes
error when trying to browse some old tickets.

Call to genshi.core's escape method with two arguments (second being
False) all fail, such as here:

    return resolver(self, ns, target, escape(label, False),
TypeError: unicode() argument 2 must be string, not bool

By modifying call to use keyword argument for second parameter, it
works. Patch below.

Full backtrace:

2012-10-09 11:30:34,656 Trac[main] ERROR: Internal Server Error: 
Traceback (most recent call last):
  File "/usr/lib/python2.6/dist-packages/trac/web/main.py", line 511, in _dispatch_request
    dispatcher.dispatch(req)
  File "/usr/lib/python2.6/dist-packages/trac/web/main.py", line 258, in dispatch
    content_type)
  File "/usr/lib/python2.6/dist-packages/trac/web/chrome.py", line 868, in render_template
    stream.render(method, doctype=doctype, out=buffer)
  File "/usr/lib/pymodules/python2.6/genshi/core.py", line 183, in render
    return encode(generator, method=method, encoding=encoding, out=out)
  File "/usr/lib/pymodules/python2.6/genshi/output.py", line 58, in encode
    for chunk in iterator:
  File "/usr/lib/pymodules/python2.6/genshi/output.py", line 339, in __call__
    for kind, data, pos in stream:
  File "/usr/lib/pymodules/python2.6/genshi/output.py", line 826, in __call__
    for kind, data, pos in stream:
  File "/usr/lib/pymodules/python2.6/genshi/output.py", line 670, in __call__
    for kind, data, pos in stream:
  File "/usr/lib/pymodules/python2.6/genshi/output.py", line 771, in __call__
    for kind, data, pos in chain(stream, [(None, None, None)]):
  File "/usr/lib/pymodules/python2.6/genshi/output.py", line 586, in __call__
    for ev in stream:
  File "/usr/lib/pymodules/python2.6/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "/usr/lib/pymodules/python2.6/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "/usr/lib/python2.6/dist-packages/trac/web/chrome.py", line 970, in _generate
    for kind, data, pos in stream:
  File "/usr/lib/pymodules/python2.6/genshi/template/base.py", line 605, in _include
    for event in stream:
  File "/usr/lib/pymodules/python2.6/genshi/template/markup.py", line 378, in _match
    ctxt, start=idx + 1, **vars):
  File "/usr/lib/pymodules/python2.6/genshi/template/markup.py", line 378, in _match
    ctxt, start=idx + 1, **vars):
  File "/usr/lib/pymodules/python2.6/genshi/template/markup.py", line 327, in _match
    for event in stream:
  File "/usr/lib/pymodules/python2.6/genshi/template/base.py", line 545, in _flatten
    for kind, data, pos in stream:
  File "/usr/lib/pymodules/python2.6/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "/usr/lib/pymodules/python2.6/genshi/path.py", line 588, in _generate
    subevent = next()
  File "/usr/lib/pymodules/python2.6/genshi/template/base.py", line 605, in _include
    for event in stream:
  File "/usr/lib/pymodules/python2.6/genshi/template/markup.py", line 316, in _strip
    event = next()
  File "/usr/lib/pymodules/python2.6/genshi/template/base.py", line 545, in _flatten
    for kind, data, pos in stream:
  File "/usr/lib/pymodules/python2.6/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "/usr/lib/pymodules/python2.6/genshi/path.py", line 588, in _generate
    subevent = next()
  File "/usr/lib/pymodules/python2.6/genshi/template/base.py", line 605, in _include
    for event in stream:
  File "/usr/lib/pymodules/python2.6/genshi/template/markup.py", line 316, in _strip
    event = next()
  File "/usr/lib/pymodules/python2.6/genshi/template/base.py", line 565, in _flatten
    result = _eval_expr(data, ctxt, vars)
  File "/usr/lib/pymodules/python2.6/genshi/template/base.py", line 277, in _eval_expr
    retval = expr.evaluate(ctxt)
  File "/usr/lib/pymodules/python2.6/genshi/template/eval.py", line 178, in evaluate
    return eval(self.code, _globals, {'__data__': data})
  File "/usr/lib/python2.6/dist-packages/trac/ticket/templates/ticket_change.html", line 61, in <Expression u'wiki_to_html(context, change.comment, escape_newlines=preserve_newlines)'>
    <py:otherwise>${wiki_to_html(context, change.comment, escape_newlines=preserve_newlines)}</py:otherwise>
  File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 1499, in format_to_html
    return HtmlFormatter(env, context, wikidom).generate(escape_newlines)
  File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 1454, in generate
    escape_newlines)
  File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 1242, in format
    result = re.sub(self.wikiparser.rules, self.replace, line)
  File "/usr/lib/python2.6/re.py", line 151, in sub
    return _compile(pattern, 0).sub(repl, string, count)
  File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 1160, in replace
    replacement = self.handle_match(fullmatch)
  File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 1156, in handle_match
    return internal_handler(match, fullmatch)
  File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 708, in _macrolink_formatter
    return self._lhref_formatter(match, fullmatch)
  File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 540, in _lhref_formatter
    return self._make_lhref_link(match, fullmatch, rel, ns, target, label)
  File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 581, in _make_lhref_link
    fullmatch)
  File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 589, in _make_link
    return resolver(self, ns, target, escape(label, False),
TypeError: unicode() argument 2 must be string, not bool



Following patch fixes this at least on our backports environment:

--- formatter.py~	2011-02-01 00:05:49.000000000 +0200
+++ formatter.py	2012-10-09 11:33:01.000000000 +0300
@@ -586,10 +586,10 @@
         if ns in self.wikiparser.link_resolvers:
             resolver = self.wikiparser.link_resolvers[ns]
             if arity(resolver) == 5:
-                return resolver(self, ns, target, escape(label, False),
+                return resolver(self, ns, target, escape(label, quotes=False),
                                 fullmatch)
             else:
-                return resolver(self, ns, target, escape(label, False))
+                return resolver(self, ns, target, escape(label, quotes=False))
         elif ns == "mailto":
             from trac.web.chrome import Chrome
             chrome = Chrome(self.env)
@@ -1285,11 +1285,11 @@
     def _indent_formatter(self, match, fullmatch):
         return match
     def _citation_formatter(self, match, fullmatch):
-        return escape(match, False)
+        return escape(match, quotes=False)
     def _heading_formatter(self, match, fullmatch):
-        return escape(match, False)
+        return escape(match, quotes=False)
     def _definition_formatter(self, match, fullmatch):
-        return escape(match, False)
+        return escape(match, quotes=False)
     def _table_cell_formatter(self, match, fullmatch):
         return match
     def _table_row_sep_formatter(self, match, fullmatch):


-- System Information:
Debian Release: 6.0.6
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-5-amd64 (SMP w/8 CPU cores)
Locale: LANG=fi_FI.UTF-8, LC_CTYPE=fi_FI.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages trac depends on:
ii  python                  2.6.6-3+squeeze7 interactive high-level object-orie
ii  python-genshi           0.6-1            Python XML-based template engine
ii  python-pkg-resources    0.6.14-4         Package Discovery and Resource Acc
ii  python-setuptools       0.6.14-4         Python Distutils Enhancements (set
ii  python2.5               2.5.5-11         An interactive high-level object-o
ii  python2.6               2.6.6-8+b1       An interactive high-level object-o

Versions of packages trac recommends:
ii  apache2                2.2.16-6+squeeze8 Apache HTTP Server metapackage
ii  apache2-mpm-prefork [h 2.2.16-6+squeeze8 Apache HTTP Server - traditional n
pn  python-babel           <none>            (no description available)
ii  python-docutils        0.7-2             utilities for the documentation of
ii  python-pygments        1.3.1+dfsg-1      syntax highlighting package writte
ii  python-subversion      1.6.12dfsg-6      Python bindings for Subversion
ii  python-tz              2010b-1           Python version of the Olson timezo

Versions of packages trac suggests:
pn  libapache2-mod-wsgi           <none>     (no description available)
pn  python-textile                <none>     (no description available)
pn  trac-accountmanager           <none>     (no description available)
pn  trac-authopenid               <none>     (no description available)
pn  trac-bitten                   <none>     (no description available)
pn  trac-bzr                      <none>     (no description available)
pn  trac-customfieldadmin         <none>     (no description available)
pn  trac-email2trac               <none>     (no description available)
pn  trac-git                      <none>     (no description available)
pn  trac-graphviz                 <none>     (no description available)
pn  trac-ja-resource              <none>     (no description available)
pn  trac-mastertickets            <none>     (no description available)
pn  trac-mercurial                <none>     (no description available)
pn  trac-spamfilter               <none>     (no description available)
pn  trac-wikiprint                <none>     (no description available)
pn  trac-wikirename               <none>     (no description available)
pn  trac-wysiwyg                  <none>     (no description available)
pn  trac-xmlrpc                   <none>     (no description available)



More information about the Python-apps-team mailing list