Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Can pdb be set to break on warnings?

Reply
Thread Tools

Can pdb be set to break on warnings?

 
 
LorcanM
Guest
Posts: n/a
 
      10-11-2006
Hello,

I use pdb under Linux to debug my Python code, as in:

python -m pdb myprogram.py

By default it does a postmortem of unhandled exceptions, is there a way
to get it to break on warnings?

Thanks a lot,


Lorcan.

 
Reply With Quote
 
 
 
 
Fredrik Lundh
Guest
Posts: n/a
 
      10-11-2006
LorcanM wrote:

> I use pdb under Linux to debug my Python code, as in:
>
> python -m pdb myprogram.py
>
> By default it does a postmortem of unhandled exceptions, is there a way
> to get it to break on warnings?


is

python -m pdb -Werror myprogram.py

what you're looking for ?

</F>

 
Reply With Quote
 
 
 
 
LorcanM
Guest
Posts: n/a
 
      10-11-2006
Fredrik Lundh wrote:
> LorcanM wrote:
>
> > I use pdb under Linux to debug my Python code, as in:
> >
> > python -m pdb myprogram.py
> >
> > By default it does a postmortem of unhandled exceptions, is there a way
> > to get it to break on warnings?

>
> is
>
> python -m pdb -Werror myprogram.py
>
> what you're looking for ?
>
> </F>



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

Thanks for the help,


Lorcan.

 
Reply With Quote
 
Fredrik Lundh
Guest
Posts: n/a
 
      10-11-2006
"LorcanM" wrote:

>> python -m pdb -Werror myprogram.py

>
> 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 myprogram.py

(-m script must be the last option before the script arguments, for pretty
obvious reasons).

</F>



 
Reply With Quote
 
Gabriel Genellina
Guest
Posts: n/a
 
      10-11-2006
At Wednesday 11/10/2006 07:31, LorcanM wrote:

> >
> > python -m pdb -Werror myprogram.py
> >

>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


Try: python -h


--
Gabriel Genellina
Softlab SRL





__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas

 
Reply With Quote
 
LorcanM
Guest
Posts: n/a
 
      10-11-2006

Fredrik Lundh wrote:
> "LorcanM" wrote:
>
> >> python -m pdb -Werror myprogram.py

> >
> > 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 myprogram.py
>
> (-m script must be the last option before the script arguments, for pretty
> obvious reasons).
>
> </F>



Thanks for that - that does the trick,


Lorcan.

 
Reply With Quote
 
R. Bernstein
Guest
Posts: n/a
 
      10-14-2006
This seems like very useful information. In the documentation I've
been maintaining for the extended python debugger
(http://bashdb.sf.net/pydb) I've added this as a little footnote:
http://bashdb.sourceforge.net/pydb/p....html#foot1113

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
work?

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" <(E-Mail Removed)> writes:

> "LorcanM" wrote:
>
> >> python -m pdb -Werror myprogram.py

> >
> > 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 myprogram.py
>
> (-m script must be the last option before the script arguments, for pretty
> obvious reasons).
>
> </F>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
set pdb break condition based upon number of hits? Reckoner Python 1 11-05-2009 01:41 AM
`if (!p ? i++ : 0) break;' == `if (!p){ i++; break;}' ? lovecreatesbea...@gmail.com C Programming 12 04-14-2008 07:59 AM
Palm::PDB: How to compose a PDB? Josef Moellers Perl Misc 0 08-16-2007 02:29 PM
Why can I still hit the break point without the pdb file =?Utf-8?B?SmF6eg==?= ASP .Net 1 06-13-2004 02:46 PM
Can I convert palm pdb format to text Chris Computer Support 1 02-08-2004 07:53 AM



Advertisments