[SciPy-dev] How to handle exceptional cases in algorithms ? Exception vs Warning

Charles R Harris charlesr.harris@gmail....
Tue Jun 5 12:02:29 CDT 2007


On 6/4/07, Robert Kern <robert.kern@gmail.com> wrote:
>
> Anne Archibald wrote:
>
> > Just a, uh, warning: I found that it was very difficult to make the
> > warnings module do what it was documented to do in terms of throwing
> > exceptions and warning the right number of times.
>
> Can you give an example? I thought it was fairly straightforward. The only
> niggle is interactive use. After the first time a warning is issued (and
> not
> raised as an error), the warning, including its message and the location
> in the
> file, is stored in a registry in the module containing the warn() call.
> Consequently, if you run interactively, see a warnings, set a filter to
> raise an
> exception instead of printing the warning, then try the bad function
> again, you
> don't get an exception.


Yeah, I had that problem too. I just removed the registry storage for
warnings. I think it is a bug, it should be possible to set the number of
times a warning is issued. IIRC,  the warnings module claims that this is
possible, but it doesn't work correctly.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-dev/attachments/20070605/41664024/attachment.html 


More information about the Scipy-dev mailing list