Edgewall Software
Modify

Opened 17 years ago

Closed 17 years ago

#4249 closed defect (worksforme)

Error reporting fails for some Genshi syntax errors

Reported by: Christian Boos Owned by: Jonas Borgström
Priority: normal Milestone:
Component: general Version: devel
Severity: minor Keywords: genshi
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

The initial problem was due to a Genshi syntax error in the template:

<span py:if="$change.ipnr" class="ipnr">(IP: $change.ipnr)</span>

(the "$" in the py:if)

But this failed to be properly reported in error.html. Instead, I got this raw backtrace:

Traceback (most recent call last):
  File "C:\Workspace\src\trac\trunk\trac\web\api.py", line 329, in send_error
    'text/html')
  File "C:\Workspace\src\trac\trunk\trac\web\chrome.py", line 514, in render_template
    return stream.render(method, doctype=doctype)
  File "c:\workspace\src\trac\genshi\trunk\genshi\core.py", line 146, in render
    output = u''.join(list(generator))
  File "c:\workspace\src\trac\genshi\trunk\genshi\output.py", line 203, in __call__
    for kind, data, pos in stream:
  File "c:\workspace\src\trac\genshi\trunk\genshi\output.py", line 489, in __call__
    for kind, data, pos in chain(stream, [(None, None, None)]):
  File "c:\workspace\src\trac\genshi\trunk\genshi\output.py", line 439, in __call__
    for kind, data, pos in stream:
  File "c:\workspace\src\trac\genshi\trunk\genshi\core.py", line 207, in _ensure
    for event in stream:
  File "c:\workspace\src\trac\genshi\trunk\genshi\core.py", line 207, in _ensure
    for event in stream:
  File "C:\Workspace\src\trac\trunk\trac\web\chrome.py", line 534, in _strip_accesskeys
    for kind, data, pos in stream:
  File "c:\workspace\src\trac\genshi\trunk\genshi\core.py", line 207, in _ensure
    for event in stream:
  File "C:\Workspace\src\trac\trunk\trac\web\chrome.py", line 523, in _generate
    for kind, data, pos in stream:
  File "c:\workspace\src\trac\genshi\trunk\genshi\template\markup.py", line 188, in _include
    for event in stream:
  File "c:\workspace\src\trac\genshi\trunk\genshi\template\markup.py", line 256, in _match
    content = list(self._include(content, ctxt))
  File "c:\workspace\src\trac\genshi\trunk\genshi\template\markup.py", line 188, in _include
    for event in stream:
  File "c:\workspace\src\trac\genshi\trunk\genshi\template\markup.py", line 231, in _match
    for event in stream:
  File "c:\workspace\src\trac\genshi\trunk\genshi\template\markup.py", line 220, in _strip
    event = stream.next()
  File "c:\workspace\src\trac\genshi\trunk\genshi\template\core.py", line 320, in _eval
    result = data.evaluate(ctxt)
  File "c:\workspace\src\trac\genshi\trunk\genshi\template\eval.py", line 114, in evaluate
    {'data': data})
  File "C:\Workspace\src\trac\trunk\templates\error.html", line 148, in <Expression u"shorten_line(repr(value))">
    <td><code>${shorten_line(repr(value))}</code></td>
  File "c:\workspace\src\trac\genshi\trunk\genshi\template\directives.py", line 94, in __repr__
    if self.expr is not None:
AttributeError: expr

I already had this kind of error before, but now it's the first time I find an easy and reproducible way to trigger it.

With [Genshi 455/trunk].

Attachments (0)

Change History (5)

comment:1 by Christopher Lenz, 17 years ago

So shouldn't you file this on the Genshi site, then? Or is it specific to the way Trac handles these errors?

comment:2 by Christian Boos, 17 years ago

I'm not sure actually, I thought you should know ;)

comment:3 by Christian Boos, 17 years ago

Ok, more precisely, there's this problematic bit in error.html:

<code>${shorten_line(repr(value))}</code>

which already failed in the past for me, quite mysteriously with an unicode error.

I have the impression that the repr here sometimes doesn't work well when value is a directive.

The bug lies probably in Genshi, but it's the special way we use it in Trac that trigger that. So I'm not sure where to start…

comment:4 by Christopher Lenz, 17 years ago

Okay, that instance should be fixed in G:r462, but others are still lurking in the code.

in reply to:  3 comment:5 by Christian Boos, 17 years ago

Milestone: 0.11
Resolution: worksforme
Status: newclosed

Replying to cboos:

Ok, more precisely, there's this problematic bit in error.html:

<code>${shorten_line(repr(value))}</code>

which already failed in the past for me, quite mysteriously with an unicode error.

Like that:

    <td><code>${shorten_line(repr(value))}</code></td>
UnicodeEncodeError: 'ascii' codec can't encode characters in position 14-15: ordinal not in range(128)

… and this was quite likely due to the value being an object whose __repr__ method was returning an unicode string. This doesn't work anymore with Python 2.5, see #5405.

As the original report was about something that got fixed in Genshi and the other similar issues I had can probably be related to the above problem, I think we can close this ticket now.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jonas Borgström.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jonas Borgström to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.