Modify

Opened 12 years ago

Closed 12 years ago

#10814 closed defect (fixed)

TypeError: 'int' object is not iterable

Reported by: paulcoddington@… Owned by: Ryan J Ollos
Priority: normal Component: WikiTableMacro
Severity: blocker Keywords:
Cc: Trac Release: 0.10

Description

TypeError: 'int' object is not iterable

Sample Wiki markup:

{{{
#!SQLTable
    SELECT count(id) as 'Number of Tickets'
    FROM ticket
}}}

Error produced when count of Tickets > 0

Trac 1.0, Windows 7 (x64), Python 2.7.x (x86)

Attachments (0)

Change History (6)

comment:1 Changed 12 years ago by Ryan J Ollos

I'm not sure if it will be relevant, but what DB are you using?

comment:2 Changed 12 years ago by paulcoddington@…

Just the default SQLite DB.

comment:3 Changed 12 years ago by Juan Manuel

I have the exact same error on Trac v1.0 running on Gentoo Linux and python 2.7

comment:4 Changed 12 years ago by Jun Omae

Reproduced. The stacktrace is here.

...
  File "/home/jun66j5/venv/trac/1.0.1/lib/python2.5/site-packages/trac/wiki/formatter.py", line 343, in _macro_processor
    text)
  File "/home/jun66j5/src/trac/trac-hacks/wikitablemacro/trunk/wikitable/table.py", line 68, in expand_macro
    format_to_html(self.env, formatter.context, col)
  File "/home/jun66j5/venv/trac/1.0.1/lib/python2.5/site-packages/trac/wiki/formatter.py", line 1546, in format_to_html
    return HtmlFormatter(env, context, wikidom).generate(escape_newlines)
  File "/home/jun66j5/venv/trac/1.0.1/lib/python2.5/site-packages/trac/wiki/formatter.py", line 1501, in generate
    escape_newlines)
  File "/home/jun66j5/venv/trac/1.0.1/lib/python2.5/site-packages/trac/wiki/formatter.py", line 1237, in format
    for line in text:
TypeError: 'int' object is not iterable

The 3rd argument, wikidom, of format_to_html expects a instance of str, unicode or iterable.

  • wikitable/table.py

     
    1616from trac.wiki.formatter import system_message, format_to_html
    1717from trac.wiki.macros import WikiMacroBase
    1818from trac.util.html import Markup
    19 from trac.util.text import exception_to_unicode
     19from trac.util.text import to_unicode, exception_to_unicode
    2020from trac.util.translation import _
    2121
    2222class SQLTable(WikiMacroBase):
     
    6464            css_class = (idx % 2 == 0) and 'odd' or 'even'
    6565            print >> out, "  <tr class='%s'>" % css_class
    6666            for col in row:
     67                if col is None:
     68                    col = "''(NULL)''"
     69                elif col is True:
     70                    col = 'TRUE'
     71                elif col is False:
     72                    col = 'FALSE'
     73                elif not isinstance(col, basestring):
     74                    col = to_unicode(col)
    6775                print >> out, "<td>%s</td>" % \
    6876                    format_to_html(self.env, formatter.context, col)
    6977            print >> out, "  </tr>"

comment:5 Changed 12 years ago by Ryan J Ollos

Thank you for the patch Jun. I'll test and apply it.

I don't have a lot of interest in this macro, so if someone else wants to take over maintenance I'm more than willing to hand it over.

comment:6 Changed 12 years ago by Ryan J Ollos

Resolution: fixed
Status: newclosed

(In [12646]) Fixes #10814: Patch by Jun Omae (jun66j5) to fix a regression introduced in [12459]. Ensure that a string is passed to format_to_html.

Lightly tested against Trac 1.1.2dev-r11682.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.