[Mailman-Users] mailman-users at python.org line 340 is broken

Mark Sapiro msapiro at value.net
Mon Jan 10 18:56:46 CET 2005

Mike Sandler wrote:

>Let me start by saying that I don't know Python.   Not even a little.

>I got the following error:
>Traceback (most recent call last):
>  File "/usr/local/mailman/scripts/driver", line 87, in run_main
>    main()
>  File "/usr/local/mailman/Mailman/Cgi/admin.py", line 175, in main
>    change_options(mlist, category, subcat, cgidata, doc)
>  File "/usr/local/mailman/Mailman/Cgi/admin.py", line 1296, in
>    gui.handleForm(mlist, category, subcat, cgidata, doc)
>  File "/usr/local/mailman/Mailman/Gui/Privacy.py", line 510, in
>    GUIBase.handleForm(self, mlist, category, subcat, cgidata, doc)
>  File "/usr/local/mailman/Mailman/Gui/GUIBase.py", line 158, in
>    doc.addError(
>  File "/usr/local/mailman/Mailman/htmlformat.py", line 340, in addError
>    self.AddItem(Header(3, Bold(FontAttr(
>TypeError: not enough arguments for format string
>and the forums seemed to be no help.
>I tracked down the offending line:
>       self.AddItem(Header(3, Bold(FontAttr(
>            _(tag), color=mm_cfg.WEB_ERROR_COLOR, size='+2')).Format() +
>                            Italic(errmsg % args).Format()))
>The problem seems to be in the Italic(errmsg % args).Format() part of it
>(trial and error)
>I got my code to not bomb and give me a readable error with:
>        self.AddItem(Header(3, Bold(FontAttr( _(tag),
>color=mm_cfg.WEB_ERROR_COLOR, size='+2')).Format() ))
>        self.AddItem(Header(3, Bold(FontAttr( errmsg,
>color=mm_cfg.WEB_ERROR_COLOR, size='+2')).Format() ))
>I am sure this is not ideal - I am sure that someone who knows the lang
>can come up with something better - but this allowed me to find my error
>(a bad email address) and fix it.

All your change did was show you the format string which you could have
seen in the source of the calling module (one line above in the trace)

>  File "/usr/local/mailman/Mailman/Gui/GUIBase.py", line 158, in

The code in addError should not be changed. It is called from many
places and it ought to work as is.

The real issue is why did (errmsg % args) not work in this case. errmsg
(in English at least) is 'Bad email address for option %(property)s:
%(val)s'. Evidently args didn't have appropriate values for 'property'
and 'val'. This is what should be addressed. What was the actual entry
in what place on what page that caused the error?

Mark Sapiro <msapiro at value.net>       The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan

More information about the Mailman-Users mailing list