[Python-Dev] breaking an exception chain

R. David Murray rdmurray at bitdance.com
Tue Aug 3 19:07:38 CEST 2010


Working with Catherine on an argparse bug, we ran into a test that was
apparently failing by raising a SystemExit, when the test harness was
supposed to be catching that error.  It took us a bit to realize that
there wasn't really a SystemExit error, but that what we were seeing was
the SystemExit chained to the exception the test harness was purposfully
raising after catching the SystemExit.  In Python2, only the second,
intentionally raised exception would be printed by unittest.  In Python3,
the "main error" printed by unittest is the SystemExit, and the error
raised by the test harness appears after the "while processing the above
error" sentence.  Needless to say, this is a bit confusing.

So I thought I'd break the exception chain before raising the error the
test harness really wants to raise.  However, I can't figure out any way
to do that.  Am I missing something, or this a missing feature?

--
R. David Murray                                      www.bitdance.com


More information about the Python-Dev mailing list