Modify

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#441 closed defect (fixed)

0.10-incompatibility: Broken.

Reported by: Dinko Korunic <dinko.korunic@…> Owned by: athomas
Priority: normal Component: TocMacro
Severity: normal Keywords: toc, formatter
Cc: Trac Release: 0.10

Description

With Trac trunk (r3411) it stopped working with KeyError (check attached log). Code according to backtrace seems this section:

def _heading_formatter(self, match, fullmatch):
  ...
  anchor = self._anchors[-1]
  ...

I have modified it to the following (code taken from Trac Wiki formatter directly):

def _heading_formatter(self, match, fullmatch):
  ...
  anchor = fullmatch.group('hanchor') or ''
  ...

Seems to be working now. Hope this helps.

Attachments (8)

trac.log (1.5 KB) - added by Dinko Korunic <dinko.korunic@…> 9 years ago.
Trac backtrace of TocMacro error
macro.py (7.5 KB) - added by cboos 9 years ago.
TocMacro's macro.py file updated for 0.10. Time to make a new branch for it! The macro has not been thoroughly tested, but this appears to work. Compatible with [T3412]. (take 2)
cboos-macro.py.patch (8.3 KB) - added by maxb 9 years ago.
The effective changes from cboos' macro.py, cleaned up and shown as a patch
fix441.patch (2.1 KB) - added by maxb 9 years ago.
See comment:8
tweaks.patch (2.5 KB) - added by maxb 9 years ago.
See comment:8
linewrap.patch (3.2 KB) - added by maxb 9 years ago.
See comment:8
wmbref.patch (1.5 KB) - added by maxb 9 years ago.
See comment:8
011notes.patch (1.7 KB) - added by maxb 9 years ago.
See comment:8

Download all attachments as: .zip

Change History (19)

Changed 9 years ago by Dinko Korunic <dinko.korunic@…>

Trac backtrace of TocMacro error

comment:1 in reply to: ↑ description ; follow-up: Changed 9 years ago by anonymous

Replying to anonymous:

With Trac trunk (r3411) it stopped working with KeyError (check attached log).

Actually, this changed in [T3408].

def _heading_formatter(self, match, fullmatch):
  ...
  anchor = fullmatch.group('hanchor') or ''
  ...

No, that's not a correct fix. See the abovementioned change for an example about how to get the anchor. The hanchor group is for an optional, explicitely given id, which, most of the time, will not be given.

comment:2 in reply to: ↑ 1 Changed 9 years ago by cboos

Replying to anonymous: ... That anonymous was me (and the above comment made me spot a little bug with the reply to description feature, which I just fixed [T3412])

Changed 9 years ago by cboos

TocMacro's macro.py file updated for 0.10. Time to make a new branch for it! The macro has not been thoroughly tested, but this appears to work. Compatible with [T3412]. (take 2)

comment:3 Changed 9 years ago by Dinko Korunic <dinko.korunic@…>

You're right, I've just checked. Thanks. Will checkout latest TocMacro.

comment:4 Changed 9 years ago by maxb

Whilst MyOutlineFormatter.format is being tweaked, purely as a clarification, the following three lines could be moved outside the enclosing for loop:

36 	            active = ''
37 	            if page == active_page:
38 	                active = ' class="active"'

...since neither page nor active_page changes from one loop iteration to the next.

comment:5 Changed 9 years ago by maxb

  • Trac Release changed from 0.9 to 0.10

comment:6 Changed 9 years ago by maxb

cboos' macro.py suffers from inconsistent indentation schemes, and also, I think, introduces some bugs by accidentally shifting some statements to different block levels.

I've cleaned up the indentation and put the shifted statements back to their original block level, and am attaching the result as a patch....

Changed 9 years ago by maxb

The effective changes from cboos' macro.py, cleaned up and shown as a patch

comment:7 Changed 9 years ago by cboos

Right, I remember I had trouble with the indentation, not sure why, as the original file seems to be correctly indented.

I could make a 0.10 version using your patch (+ the other change you suggested), if athomas would give me the perms for that plugin...

comment:8 Changed 9 years ago by maxb

  • Summary changed from Stopped working with trac trunk, error in using anchor to 0.10-incompatibility: Broken.

I've split up cboos' patch into multiple changes:

  • fix441: Fix this ticket. (also, added the change I suggested in comment:4)
  • tweaks: General refactoring.
  • linewrap: Wrap overly long lines.
  • wmbref: Convert to WikiMacroBase.
  • 011notes: Add notes about 0.11.

(These should be applied in that order - they have interdependencies.)

Additionally, cboos' patch contained:

  • Removal of trailing whitespace: I've not included that in the above patches, since it is easier for a committer to run a simple editor command, than review a patch doing the same (but it would be nice to have this done).
  • Introduction of coding: utf-8 statement: I've dropped that, since it was only there to support the addition of a weird angled quote character in an added comment, which looked like a typo anyway.
  • Placing of an assignment to args into an else: clause: I've removed this change, since it results in args being a different datatype (string vs. list) depending on whether args are provided, which doesn't seem right.
  • A couple of odd whitespace changes within lines: I left these out.

I will now attach the 5 patch files.

Changed 9 years ago by maxb

See comment:8

Changed 9 years ago by maxb

See comment:8

Changed 9 years ago by maxb

See comment:8

Changed 9 years ago by maxb

See comment:8

Changed 9 years ago by maxb

See comment:8

comment:9 Changed 9 years ago by maxb

Oops! There's an error in various places throughout cboos' macro.py and my derivatives:

out.write(system_message(MESSAGE), None)

is supposed to be:

out.write(system_message(MESSAGE, None))

The error is present in the first of two uses of system_message in macro.py. In tweaks.patch, I accidentally spread the error to the second use too. In linewrap.patch, there's one change which isn't a pure line-wrap: the accidental spreading is undone again.

Rather than re-attaching fixed versions of tweaks.patch and linewrap.patch, please just correct the placement of the parentheses as described above, in tweaks.patch and linewrap.patch, before applying them - thanks!

comment:10 Changed 9 years ago by coderanger

  • Resolution set to fixed
  • Status changed from new to closed

(In [927]) Intergrating several patches from #441. Thanks to cboos and maxb for sorting this out. Closes #441.

comment:11 Changed 9 years ago by cboos

Yep, thanks for the fixes to my fixes, maxb :)

Also, the system_message was slightly improved in [T3431].

Lastly, don't hesitate to comment and brainstorm further relative to the attachment:011notes.patch

Add Comment

Modify Ticket

Action
as closed The owner will remain athomas.
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.