PEP 317: Eliminate Implicit Exception Instantiation
bh at intevation.de
Mon Jun 9 22:33:13 CEST 2003
Steven Taschuk <staschuk at telusplanet.net> writes:
> Quoth Bernhard Herzog:
> > Steven Taschuk <staschuk at telusplanet.net> writes:
> > > Part of my problem here is that I'm not
> > > familiar enough with real-life uses of the traceback argument. Do
> > > you use it?
> > Yes, occasionally.
> I'd like to hear more about this -- in what circumstances, and to
> what end?
One is in the XFig import filter in Sketch (paraphrasing a bit):
tokens = tokenize(line, 1)
# dispatch on tokens
line = self.readline()
except SketchLoadError, value:
raise SketchLoadError('%d:%s' % (self.lineno, str(value))), None,\
So, basically it's there to put some more information into the error
message. Not all places where SketchLoadError is raised have access to
the line number so it can't easily be done in other ways.
I'm not sure why it uses exc_traceback instead of sys.exc_info() but
the xfig filter is quite old and the code in question might predate
Python 1.5 where exc_info() was introduced. Anyway, Sketch doesn't use
threads so it shouldn't be a problem unless somebody now goes and starts
deprecating sys.exc_traceback ;-)
Intevation GmbH http://intevation.de/
More information about the Python-list