Edgewall Software

Opened 8 years ago

Last modified 8 years ago

#12285 closed defect

AttributeError: 'TracError' object has no attribute 'replace' — at Version 2

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Milestone: 1.0.10
Component: timeline Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:

Fixed AttributeError when an exception passed to add_notice or add_warning contained text that needed to be escaped (e.g. &&). The error was only seen when Genshi was installed without speedups.

API Changes:
Internal Changes:

Description

[pid 23749 140573412329216] 2015-12-17 10:06:48,386 Trac[main] ERROR: Internal Server Error: <RequestWithSession "GET '/timeline?from=2008-12-03T10:14:17+01:00&precision=second'">, referrer None
Traceback (most recent call last):
  File "/usr/local/virtualenv/1.1dev/lib/python2.7/site-packages/trac/web/main.py", line 594, in _dispatch_request
    dispatcher.dispatch(req)
  File "/usr/local/virtualenv/1.1dev/lib/python2.7/site-packages/trac/web/main.py", line 251, in dispatch
    resp = chosen_handler.process_request(req)
  File "/usr/local/virtualenv/1.1dev/lib/python2.7/site-packages/trac/timeline/web_ui.py", line 118, in process_request
    add_warning(req, e)
  File "/usr/local/virtualenv/1.1dev/lib/python2.7/site-packages/trac/web/chrome.py", line 198, in add_warning
    msg = escape(msg, False)
  File "/usr/local/virtualenv/src/trac-1.1dev/.eggs/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/core.py", line 519, in escape
    text = text.replace('&', '&amp;') \
AttributeError: 'TracError' object has no attribute 'replace'
[pid 10365 140573412329216] 2015-12-17 11:31:40,131 Trac[main] ERROR: Internal Server Error: <RequestWithSession "GET '/timeline?from=2011-02-02T11:38:50+01:00&precision=second'">, referrer 'http://trac.edgewall.org/wiki/TranslationRu'
Traceback (most recent call last):
  File "/usr/local/virtualenv/1.1dev/lib/python2.7/site-packages/trac/web/main.py", line 594, in _dispatch_request
    dispatcher.dispatch(req)
  File "/usr/local/virtualenv/1.1dev/lib/python2.7/site-packages/trac/web/main.py", line 251, in dispatch
    resp = chosen_handler.process_request(req)
  File "/usr/local/virtualenv/1.1dev/lib/python2.7/site-packages/trac/timeline/web_ui.py", line 118, in process_request
    add_warning(req, e)
  File "/usr/local/virtualenv/1.1dev/lib/python2.7/site-packages/trac/web/chrome.py", line 198, in add_warning
    msg = escape(msg, False)
  File "/usr/local/virtualenv/src/trac-1.1dev/.eggs/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/core.py", line 519, in escape
    text = text.replace('&', '&amp;') \
AttributeError: 'TracError' object has no attribute 'replace'

Change History (2)

comment:1 by Ryan J Ollos, 8 years ago

Related to #12007. Issue is only seen for Genshi without speedups. Is the following patch the best solution?:

  • trac/web/chrome.py

    diff --git a/trac/web/chrome.py b/trac/web/chrome.py
    index 696893d..f084c04 100644
    a b def add_warning(req, msg, *args):  
    195195    """
    196196    if args:
    197197        msg %= args
    198     msg = escape(msg, False)
     198    msg = escape(to_unicode(msg), False)
    199199    if msg not in req.chrome['warnings']:
    200200        req.chrome['warnings'].append(msg)
    201201
    def add_notice(req, msg, *args):  
    209209    """
    210210    if args:
    211211        msg %= args
    212     msg = escape(msg, False)
     212    msg = escape(to_unicode(msg), False)
    213213    if msg not in req.chrome['notices']:
    214214        req.chrome['notices'].append(msg)
Last edited 8 years ago by Ryan J Ollos (previous) (diff)

comment:2 by Ryan J Ollos, 8 years ago

Release Notes: modified (diff)
Note: See TracTickets for help on using tickets.