Opened 11 years ago

Closed 10 years ago

#2058 closed defect (worksforme)

Error: Macro TOC(None) failed -1

Reported by: anonymous Owned by: Noah Kantrowitz
Priority: normal Component: TocMacro
Severity: critical Keywords:
Cc: Trac Release: 0.10


Hi, I installed the TocMacro on two servers, both FreeBSD from ports and on both servers I got this error. Python 2.5, Trac 0.10. But I'm almost sure it worked before when I was using Python 2.4 but I can't test it now...

Error: Macro TOC(None) failed

The page content is simple:

= Hi =

When I look into trac.log

2007-09-19 11:30:04,003 Trac[formatter] ERROR: Macro TOC(None) failed
Traceback (most recent call last):
  File "/usr/local/lib/python2.5/site-packages/trac/wiki/", line 441, in _macro_formatter
    return macro.process(self.req, args, True)
  File "/usr/local/lib/python2.5/site-packages/trac/wiki/", line 114, in process
    text = self.processor(req, text)
  File "/usr/local/lib/python2.5/site-packages/trac/wiki/", line 102, in _macro_processor
    return self.macro_provider.render_macro(req,, text)
  File "build/bdist.freebsd-6.2-STABLE-i386/egg/tractoc/", line 188, in render_macro
    formatter.format(current_page, page, page_text, out, params['min_depth'], params['max_depth'])
  File "build/bdist.freebsd-6.2-STABLE-i386/egg/tractoc/", line 25, in format
    Formatter.format(self, text, NullOut())
  File "/usr/local/lib/python2.5/site-packages/trac/wiki/", line 824, in format
    result = re.sub(, self.replace, line)
  File "/usr/local/lib/python2.5/", line 142, in sub
    return _compile(pattern, 0).sub(repl, string, count)
  File "/usr/local/lib/python2.5/site-packages/trac/wiki/", line 770, in replace
    replacement = self.handle_match(fullmatch)
  File "/usr/local/lib/python2.5/site-packages/trac/wiki/", line 766, in handle_match
    return internal_handler(match, fullmatch)
  File "build/bdist.freebsd-6.2-STABLE-i386/egg/tractoc/", line 53, in _heading_formatter
    anchor = self._anchors[-1]
KeyError: -1

Attachments (0)

Change History (7)

comment:1 Changed 11 years ago by anonymous

Update: there's a FreeBSD and Python 2.4.4 on the other server and I'm getting the same error.

On both servers is the 1.0 version of TocMacro.

comment:2 Changed 11 years ago by anmaster@…

Same problem. System:

  • FreeBSD 6.2
  • lighttpd-1.4.18
  • trac 0.10.4
  • tocmacro-1.0

trac runs with fast-cgi.

comment:3 Changed 11 years ago by anonymous

I also see the same thing (a stack trace would be redundant.)


  • FreeBSD 7.0 (built minimally w/ ports (source compiled software) added as needed.)
  • SERVER_SOFTWARE="Apache/2.2.6 (FreeBSD) mod_ssl/2.2.6 OpenSSL/0.9.8e DAV/2 mod_python/3.3.1 Python/2.5.1 SVN/1.4.4 PHP/5.2.4 with Suhosin-Patch"
  • fast-cgi
  • mpm=worker
  • tocmacro-1.0

I'm really new to Trac, and scavanged the tocmacro off the coderangers mirror site as best I could a few days ago. I think I've got the right one and installed it semi-correctly. Admin (plugin) shows: Toc 1.0

comment:4 Changed 11 years ago by anonymous

Oh, FWIW, I also get this error:

2007-10-08 14:34:06,090 Trac[macros] ERROR: Failed to load wiki macro ()
Traceback (most recent call last):
  File "/usr/local/lib/python2.5/site-packages/trac/wiki/", line 448, in get_macros
    yield name

Research on that (when I didn't know what TracGuideToc even was and thought it wasn't working) seemed to indicate that it was a inocuous spam type message theorized by someone to have been being an artifact of Python's garbage collector. I mention it (and the mpm detail of my earlier entry) in case it has bearing on _anchors access within the plugin or something.

(One might sense that I am desperate for a working TOC-like thing as I find the wiki to be much poorer for it's lack of one. A side-window, which is I _think_ what I would get if this were working, would be an improvement over Twiki's standard implementation I suspect.)

comment:5 Changed 11 years ago by Tom

I'm the guy who added the 10/18 changes. I've not investigated things much since, but I did register on ''.

I did want to add that my version of Trac itself is '0.10.4'

comment:6 Changed 10 years ago by anonymous

I using FreeBSD and trac 10.4. It help me to install it from directly. A simple python build and python install did it for me.

comment:7 Changed 10 years ago by osimons

Resolution: worksforme
Status: newclosed

I does not seem that the problem exists in most recent version. I've updated the installation instructions for advice on getting most recent versions, and please reopen if the problem persists.

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Noah Kantrowitz.
The resolution will be deleted.

Add Comment

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

Note: See TracTickets for help on using tickets.