NOTE: THIS IS NOT GOING TO BE SUPPORTED. EVER. I WOUND UP GIVING IN AND SPAWNING SUBPROCESSES INSTEAD.
This is a VERY dangerous library that you should only use in the direst of situations. I wrote it to scratch a rather nasty itch: linking in buggy C++ code to an otherwise pristine pure Python environment (for work of course). I wanted to be able to use Python's unittest at work, but it is known that some of the functions in the DLLs I link against can crash. The other test frameworks in the test battery cope with this by spawning a brand new process for every single test case. That's insane and this is slightly less dirty than shoehorning unittest.TestCase to run itself out of process somehow.
Windows only. I might add a simple SIGSEGV handler for Unix someday, but whatever.
import crash try: with crash.suppression: some_potentially_fatal_call() print "We will always get here" print "But never get here if there was a crash (as soon as we leave context a MemoryError is thrown)" except MemoryError: print "Some horrible crash happened, but was bravely and wrongly ignored. Life goes on!"