Edgewall Software

Opened 10 years ago

Last modified 10 years ago

#11385 closed defect

Genshi cannot handle encoded exception message when a Wiki Macros is failed — at Initial Version

Reported by: t2y <tetsuya.morimoto@…> Owned by:
Priority: low Milestone: 0.12.6
Component: wiki system Version: 1.0-stable
Severity: normal Keywords:
Cc: Ryan J Ollos, Jun Omae Branch:
Release Notes:
API Changes:
Internal Changes:

Description

I encountered this bug after my Trac was migrated 0.12 to 1.0.2dev_r12278. My Trac has many reports including Wiki Macros, and then a macro is failed for some reason like this. Our database is postgresql and it returns the encoded error message including Japanese.

2013-12-01 11:35:59,458 Trac[formatter] ERROR: Macro TicketQuery(version=v4.0,order=time,time=today..,col=id|summary|component|status|version|milestone|priority|time|reporter|qa_contact) failed:
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/Trac-1.0.2dev_r12278-py2.6.egg/trac/wiki/formatter.py", line 766, in _macro_formatter
    return macro.ensure_inline(macro.process(args))
  File "/usr/local/lib/python2.6/dist-packages/Trac-1.0.2dev_r12278-py2.6.egg/trac/wiki/formatter.py", line 357, in process
    text = self.processor(text)
  File "/usr/local/lib/python2.6/dist-packages/Trac-1.0.2dev_r12278-py2.6.egg/trac/wiki/formatter.py", line 344, in _macro_processor
    text)
  File "/usr/local/lib/python2.6/dist-packages/Trac-1.0.2dev_r12278-py2.6.egg/trac/ticket/query.py", line 1332, in expand_macro
    tickets = query.execute(req)
  File "/usr/local/lib/python2.6/dist-packages/Trac-1.0.2dev_r12278-py2.6.egg/trac/ticket/query.py", line 302, in execute
    self.num_items = self._count(sql, args)
  File "/usr/local/lib/python2.6/dist-packages/Trac-1.0.2dev_r12278-py2.6.egg/trac/ticket/query.py", line 283, in _count
    % sql, args)[0][0]
  File "/usr/local/lib/python2.6/dist-packages/Trac-1.0.2dev_r12278-py2.6.egg/trac/db/api.py", line 122, in execute
    return db.execute(query, params)
  File "/usr/local/lib/python2.6/dist-packages/Trac-1.0.2dev_r12278-py2.6.egg/trac/db/util.py", line 121, in execute
    cursor.execute(query, params)
  File "/usr/local/lib/python2.6/dist-packages/Trac-1.0.2dev_r12278-py2.6.egg/trac/db/util.py", line 65, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
ProgrammingError: 列参照"status"は曖昧です
LINE 1: SELECT COUNT(*) FROM (SELECT t.status AS status,t.summary AS...

Currently, Genshi expects the unicode string, but _macro_formatter() function doesn't consider the string type when an exception happened.

  • trac/wiki/formatter.py
     757     def _macro_formatter(self, match, fullmatch, macro, only_inline=False):      
     758         name = fullmatch.group('macroname')                                      
     759         if name.lower() == 'br':                                                 
     760             return '<br />'                                                      
     761         if name and name[-1] == '?': # Macro?() shortcut for MacroList(Macro)    
     762             args = name[:-1] or '*'                                              
     763         else:                                                                    
     764             args = fullmatch.group('macroargs')                                  
     765         try:                                                                     
     766             return macro.ensure_inline(macro.process(args))                      
     767         except Exception, e:                                                     
     768             self.env.log.error('Macro %s(%s) failed: %s' %                       
     769                     (name, args, exception_to_unicode(e, traceback=True)))       
     770             return system_message('Error: Macro %s(%s) failed' % (name, args),   
     771                                   e)
    

Change History (1)

by t2y <tetsuya.morimoto@…>, 10 years ago

patch to decode the exception

Note: See TracTickets for help on using tickets.