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

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

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 aafigure.py on line 960 and a quick work-around is to replace:
  if options['format'].lower() == 'svg':
with...
  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/__init__.py", line 1311, in run
    handler(self.page.page_name, self)
  File "/usr/lib/pymodules/python2.6/MoinMoin/action/edit.py", line 152, in execute
    pg.sendEditor(preview=savetext, comment=comment)
  File "/usr/lib/pymodules/python2.6/MoinMoin/PageEditor.py", 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/Page.py", line 1201, in send_page
    start_line=pi['lines'])
  File "/usr/lib/pymodules/python2.6/MoinMoin/Page.py", line 1285, in send_page_content
    self.format(parser)
  File "/usr/lib/pymodules/python2.6/MoinMoin/Page.py", line 1306, in format
    parser.format(self.formatter)
  File "/usr/lib/pymodules/python2.6/MoinMoin/parser/text_moin_wiki.py", line 1546, in format
    formatted_line = self.scan(line, inhibit_p=inhibit_p)
  File "/usr/lib/pymodules/python2.6/MoinMoin/parser/text_moin_wiki.py", line 1360, in scan
    result.append(self.replace(match, inhibit_p))
  File "/usr/lib/pymodules/python2.6/MoinMoin/parser/text_moin_wiki.py", line 1404, in replace
    result.append(replace_func(hit, match.groupdict()))
  File "/usr/lib/pymodules/python2.6/MoinMoin/parser/text_moin_wiki.py", line 1295, in _parser_end_repl
    result = self.formatter.parser(self.parser_name, self.parser_lines)
  File "/usr/lib/pymodules/python2.6/MoinMoin/formatter/__init__.py", line 348, in parser
    p.format(self)
  File "/home/oliver/moin/data/plugin/parser/aafig.py", line 87, in format
    self.request.write(self.render(formatter))
  File "/home/oliver/moin/data/plugin/parser/aafig.py", line 71, in render
    visitor, output = aafigure.render(self.raw, None, options)
  File "/usr/lib/python2.6/dist-packages/aafigure/aafigure.py", 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/aafig.py'
--- examples/moinmoin/aafig.py 2009-07-04 00:11:26 +0000
+++ examples/moinmoin/aafig.py 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():
                 try:
                     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 aafigure.py 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

Patches