AssertionError not caught?

LX lxkain at gmail.com
Sun Feb 1 21:31:34 EST 2009


This one has me mystified good!

This works (print statement is executed as the Exception is caught) as
advertised:
    try:
        raise AssertionError
    except AssertionError:
        print "caught AssertionError"


But this one does not:

   def test():
        raise AssertionError

    try:
        test()
    except AssertionError:
        print "caught AssertionError"

other errors (e.g. IOError) work fine! This is on OSX 10.5.6, with the
standard Python 2.5 (r25:51918, Sep 19 2006, 08:49:13)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)].

Is this a bug? Any hints / help would be much appreciated! Thank you.



More information about the Python-list mailing list