"reraise" & Exception Transformation (was Re: Modules implicitly exposing exceptions from other modules)

Barry A. Warsaw bwarsaw at cnri.reston.va.us
Wed Feb 16 13:56:27 EST 2000


>>>>> "RH" == Randall Hopper <aa8vb at yahoo.com> writes:

    RH> Maybe a "reraise <exception>" statement in Python 2.0?

TMSA (Time Machine Strikes Again):

-------------------- snip snip --------------------
import sys

def foo():
    raise NameError

def bar():
    foo()

def baz():
    try:
        bar()
    except NameError:
        tpe, val, tb = sys.exc_info()
        raise AttributeError, None, tb

baz()
-------------------- snip snip --------------------
Python 1.5.2 (#7, Apr 16 1999, 18:24:22)  [GCC 2.8.1] on sunos5
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> ## working on region in file /tmp/python-sFAH4h...
Traceback (innermost last):
  File "<stdin>", line 1, in ?
  File "/tmp/python-sFAH4h", line 16, in ?
    baz()
  File "/tmp/python-sFAH4h", line 11, in baz
    bar()
  File "/tmp/python-sFAH4h", line 7, in bar
    foo()
  File "/tmp/python-sFAH4h", line 4, in foo
    raise NameError
AttributeError




More information about the Python-list mailing list