PEP 317: Eliminate Implicit Exception Instantiation

Bernhard Herzog bh at
Mon Jun 9 22:33:13 CEST 2003

Steven Taschuk <staschuk at> writes:

> Quoth Bernhard Herzog:
> > Steven Taschuk <staschuk at> 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):

            # ...
            while line:
                tokens = tokenize(line, 1)
                # dispatch on tokens[0]
                # ...
                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()[2] 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                       

More information about the Python-list mailing list