[Tutor] traceback

Willi Richert richert at c-lab.de
Thu Jan 15 12:02:28 CET 2009


Hi,

from http://effbot.org/pyref/sys.exc_info.htm:

"The information returned is specific both to the current thread and to the 
current stack frame. If the current stack frame is not handling an exception, 
the information is taken from the calling stack frame, or its caller, and so 
on until a stack frame is found that is handling an exception."

Maybe you are actually in two different threads?
Take also a look at http://pbe.lightbird.net/traceback-module.html

Regards,
wr

Am Donnerstag, 15. Januar 2009 11:54:50 schrieb spir:
> Le Wed, 14 Jan 2009 21:19:11 +0100,
>
> Willi Richert <w.richert at gmx.net> a écrit :
> > Hi,
> >
> > do you observe the same behavior with traceback.format_exc()? I've used
> > that always in such situations which worked all the time.
> >
> > Regards,
> > wr
>
> Actually yes, for the traceback object returned by sys.exc_info() is None.
> (sys.exc_info() --> (None,None,None)). Like if there was no exception
> raised, or like if it had been clear()ed. But when I don't catch the
> exception launched by a test program, I get the standard python error
> message and the prog stops -- which proves that there *is* an active
> exception. Simply, I cannot have it returned by sys.exc_info().
> I will try more today to understand why/when/how this happens. As I said,
> in some circomstances all works well (sys.exc_info() returns a filled
> (type,value,traceback) tuple) but as of now I cannot understand why.
>
> Denis
>
> > Am Mittwoch, 14. Januar 2009 18:09:51 schrieb spir:
> > > Hello,
> > >
> > > I rather often use exceptions as information providers at design or
> > > debug time. A typical use of mine is to have a test version of methods
> > > that wrap standard version:
> > >
> > > def run():
> > > 	do stuff
> > > 	that may
> > > 	raise exc
> > > def testRun():
> > >  	try:
> > > 		run()
> > > 	except Error,error:
> > > 		sys.error.write(str(error))
> > >
> > > So that I can run a bunch of (possibly failing) tests and still get all
> > > worthful info. Now, the drawback is that I then lose python provided
> > > traceback, as for any reason str(exc) does not return tracback, only
> > > the "message". To have the traceback I planned to catch the traceback
> > > manually. The aims whare:
> > > * be able to output the tracback prepended to the message, when useful
> > > * try to find a more readable (for me) format
> > > * filter it: e.g. print only last trace mark of each module
> > > If you have ideas on the best way to do this, thanks.
> > >
> > > I tried to use sys.exc_info() that returns a (type,value,traceback)
> > > tuple and the format_tb() function of the traceback module. *Sometimes*
> > > I get the traceback as expected and all is fine. But in most cases
> > > sys.exc_info() returns (None,None,None) like if there was absolutely no
> > > active exception. I cannot consistently reproduce the issue to make a
> > > clear diagnosis.
> > >
> > > Thank you,
> > > Denis
> > >
> > > ------
> > > la vida e estranya
> > > _______________________________________________
> > > Tutor maillist  -  Tutor at python.org
> > > http://mail.python.org/mailman/listinfo/tutor
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
>
> ------
> la vida e estranya
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Dipl.-Inform. Willi Richert
C-LAB - Cooperative Computing & Communication Laboratory
 der Universität Paderborn und Siemens

FU.323
Fürstenallee 11
D-33102 Paderborn
Tel: +49 5251 60 6120
Fax: +49 5251 60 6065
http://www.c-lab.de


More information about the Tutor mailing list