[Python-3000] Exceptions internals and removing sys.exc_*

Steven Bethard steven.bethard at gmail.com
Tue Jan 23 18:57:00 CET 2007


On 1/23/07, Thomas Wouters <thomas at python.org> wrote:
> On 1/23/07, Steven Bethard <steven.bethard at gmail.com> wrote:
> > Sorry, for those of us following along at home ;-) could someone
> > explain why we couldn't just introduce a ``sys.get_exception()`` or
> > something like that which would then make the exception (and therefore
> > the traceback) available?
>
> We could, of course, but what's the point? To rename the existing 'exc_info'
> into 'get_exception' and some attribute-retrieval? I'm all for cleanup and
> not looking back, but that's quite a lot of gratuitous breakage, to little
> point. I don't consider it 'weird' or 'bad' or 'a wart' or 'a hysterical
> raisin' that sys.exc_info() returns a tuple of three things.

If I understand it right, all three elements of the sys.exc_info()
tuple are derivable from only the middle element (at least in Python
3.0 where the middle element would always have to be an exception
instance[1])::

    def exc_info():
        exc = sys.get_exception()
        return exc.__class__, exc, exc.__traceback__

So I guess it just seems a little redundant to return a tuple of three
things when two of the three are easily derivable from the third.  I
was trying to think of any other API in Python which does something
like this, but I couldn't find one...


[1] http://docs.python.org/lib/module-sys.html
"The values returned are (type, value, traceback). Their meaning is:
... ``value`` gets the exception parameter (its associated value  or
the second argument to raise, which is always a class instance if the
exception type is a class object)"

STeVe
-- 
I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a
tiny blip on the distant coast of sanity.
        --- Bucky Katt, Get Fuzzy


More information about the Python-3000 mailing list