Set -Werror *inside* Python (Was Re: Can pdb be set to break on warnings?)

R. Bernstein rocky at
Sat Oct 14 05:27:34 CEST 2006

This seems like very useful information. In the documentation I've
been maintaining for the extended python debugger
( I've added this as a little footnote:

However since pydb allows for options on it's own, I wonder if there
might not be a way do this from *inside* a Python
debugger/program. Specifically so that when an execfile is called, it
is as though -Werror were given initially. Possibly by setting
sys.warnoptions? Anyone know offhand if that or something else will

I'll do the testing myself if someone can give a small python program
that gives such a warning. (I realize most people contributing to
comp.lang.python write programs flawlessly the first time so they've
never come across such a warning message either, let alone have need
for a debugger; but this thread suggested that the perhaps there might
such a person who has seen a Python warning message exists. :-)

"Fredrik Lundh" <fredrik at> writes:

> "LorcanM" wrote:
> >>      python -m pdb -Werror
> >
> > It sounds like what I want, but it doesn't work for me. When I try the
> > above line of code, it replies:
> >
> > Error: -Werror does not exist
> >
> > I'm running Python 2.4.3
> sorry, pilot cut and paste error.  try:
>     python -Werror -m pdb
> (-m script must be the last option before the script arguments, for pretty
> obvious reasons).
> </F> 

More information about the Python-list mailing list