KeyError: 'format' when using through MoinMoin parser "aafig"

Bug #462593 reported by Oliver Joos on 2009-10-28
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

I get a KeyError when using aafigure 0.4 with MoinMoin parser "aafig". I use 9.10 (Karmic) with python-moinmoin 1.8.4-1ubuntu1 and python 2.6.4~rc1-0ubuntu1.

The error is raised in on line 960 and a quick work-around is to replace:
  if options['format'].lower() == 'svg':
  if 'format' not in options or options['format'].lower() == 'svg':

The exact error is:
2009-10-27 16:58:07,933 ERROR MoinMoin.failure:159 An exception occurred, URI was "/AAFigTests".
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.6/MoinMoin/request/", line 1311, in run
    handler(, self)
  File "/usr/lib/pymodules/python2.6/MoinMoin/action/", line 152, in execute
    pg.sendEditor(preview=savetext, comment=comment)
  File "/usr/lib/pymodules/python2.6/MoinMoin/", line 499, in sendEditor
    self.send_page(content_id=content_id, content_only=1, hilite_re=badwords_re)
  File "/usr/lib/pymodules/python2.6/MoinMoin/", line 1201, in send_page
  File "/usr/lib/pymodules/python2.6/MoinMoin/", line 1285, in send_page_content
  File "/usr/lib/pymodules/python2.6/MoinMoin/", line 1306, in format
  File "/usr/lib/pymodules/python2.6/MoinMoin/parser/", line 1546, in format
    formatted_line = self.scan(line, inhibit_p=inhibit_p)
  File "/usr/lib/pymodules/python2.6/MoinMoin/parser/", line 1360, in scan
    result.append(self.replace(match, inhibit_p))
  File "/usr/lib/pymodules/python2.6/MoinMoin/parser/", line 1404, in replace
    result.append(replace_func(hit, match.groupdict()))
  File "/usr/lib/pymodules/python2.6/MoinMoin/parser/", line 1295, in _parser_end_repl
    result = self.formatter.parser(self.parser_name, self.parser_lines)
  File "/usr/lib/pymodules/python2.6/MoinMoin/formatter/", line 348, in parser
  File "/home/oliver/moin/data/plugin/parser/", line 87, in format
  File "/home/oliver/moin/data/plugin/parser/", line 71, in render
    visitor, output = aafigure.render(self.raw, None, options)
  File "/usr/lib/python2.6/dist-packages/aafigure/", line 960, in render
    if options['format'].lower() == 'svg':
KeyError: 'format'

Related branches

luca (llucax) on 2009-10-28
Changed in aafigure:
milestone: none → 0.5
importance: Undecided → High
luca (llucax) wrote :

I thinks this is a better patch (because the moinmoin plug-in should select a format explicitly):

[------- CUT HERE ------]
=== modified file 'examples/moinmoin/'
--- examples/moinmoin/ 2009-07-04 00:11:26 +0000
+++ examples/moinmoin/ 2009-10-28 15:22:46 +0000
@@ -44,7 +44,7 @@
         key = 'aafigure_%s' % (cache.key(self.request, itemname=self.pagename, content="%s%s" % (self.raw, self.args)),)
         if not cache.exists(self.request, key) or not cache.exists(self.request, key+'_size'):
             # not in cache, regenerate image
- options = {}
+ options = dict(format='svg')
             for arg in self.args.split():
                     k, v = arg.split('=', 1)

[------- CUT HERE ------]

I don't have moinmoin to test it though, so if you can try it it will be appreciated. Chris, if this patch looks OK to you I can apply it.

luca (llucax) wrote :

Well launchpad decided to eat some spaces between +/- and "options = ...", but the patch really have them. I'll attach it so it won't get corrupted.

luca (llucax) on 2009-10-28
Changed in aafigure:
status: New → In Progress
Oliver Joos (oliver-joos) wrote :

Thanks! I confirm that your patch works with my setup (and is better than my quick workaround).
I also tested it with the latest 0.5.

Nevertheless I suggest another fix in aafigure.render(), so that a missing key in 'options' leads to a more predictable behavior, e.g. raises an expected UnsupportedFormatError.

Changed in aafigure:
assignee: nobody → zsquareplusc (zsquareplusc)
status: In Progress → Fix Committed
importance: High → Medium
Changed in aafigure:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers