From: Yuri T. <qar...@gm...> - 2007-11-16 02:13:53
|
Not all messages are errors, so they probably shouldn't all go to the error stream. Or should they? I think at the time I was thinking in fact of using messages for non-error messages and using print_error() for errors. Now, arguably message(CRITICAL, "...") should be interpreted as an error. Perhaps the thing to do is to follow Trent's suggestion and to yank this function out altogether and replace with with calls to logging. Less confusion. - yuri On Nov 15, 2007 5:56 PM, Waylan Limberg <wa...@gm...> wrote: > I should mention the easy fix. Just have `message` write to `sys.stderr`: > > def message(level, text) : > if level >= MESSAGE_THRESHOLD : > - print text > + print >> sys.stderr, text # or sys.stderr.write > (text+'\n') > > But, is that good enough or should we use python's built-in > error-handling? > > On Nov 15, 2007 3:35 PM, Waylan Limberg <wa...@gm...> wrote: > > > > Below is the text of the bug [1] I just filed. The reason I'm posting > > here is to get some feedback. Why was it done the way it is? Is there > > any good reason not to change? > > > > [1]: > http://sourceforge.net/tracker/index.php?func=detail&aid=1832747&group_id=153041&atid=790198 > > > > > Currently, caught errors are handled by the `message` method which > > > uses `print` to display error/warning messages. As `print` outputs to > > > `sys.stout` by default, this conflicts with the wsgi spec [1]. > > > > > > To my knowledge, wsgi_mod [2] is the only server that enforces the > > > spec here, but in doing so, any `message` generated by markdown would > > > cause a `500` response by wsgi_mod. As most any python web-framework > > > has a wsgi interface, we should expect python-markdown to be used in > > > wsgi environments repeatedly and IMO support such use. FYI, I first > > > came across the problem here [3]. > > > > > > We could just raise exceptions, but python trackbacks can be ugly > > > (especially when were dealing with an end user and markdown syntax > > > errors) and we need multiple levels. Perhaps we should be using the > > > warnings module [3] (available since Python 2.1) which outputs to > > > `sys.stderr` by default. > > > > > > [1]: http://www.python.org/dev/peps/pep-0333/#error-handling > > > [2]: http://code.google.com/p/modwsgi/wiki/DebuggingTechniques > > > [3]: http://code.djangoproject.com/ticket/2910#comment:12 > > > [4]: http://docs.python.org/lib/module-warnings.html > > > > > > -- > > ---- > > Waylan Limberg > > wa...@gm... > > > > > > -- > ---- > Waylan Limberg > wa...@gm... > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Python-markdown-discuss mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/python-markdown-discuss > -- Yuri Takhteyev Ph.D. Candidate, UC Berkeley School of Information http://takhteyev.org/, http://www.freewisdom.org/ |