"Simon Forman" <[EMAIL PROTECTED]> writes: > pycraze wrote: >> I would like to ask a question. How do one handle the exception due to >> Segmentation fault due to Python ? Our bit operations and arithmetic >> manipulations are written in C and to some of our testcases we >> experiance Segmentation fault from the python libraries. >> >> If i know how to handle the exception for Segmentation fault , it will >> help me complete the run on any testcase , even if i experiance Seg >> Fault due to any one or many functions in my testcase. > > AFAIK, seg fault kills your program dead. There's no exception to > handle. If you're getting seg faults from the python standard library, > that's a pretty serious thing, way more serious than just not-passed > testcases.
Segfault handling is platform-dependant... So, at least on unix-like platform, you can use the signal module to detect segfault: import signal def handler(signum, frame): print 'Segfault detected' # you may use the stack frame here to help debugging signal.signal(signal.SIGSEGV, handler) -- Thomas SAMSON "You're very sure of your facts, " he said at last, "I couldn't trust the thinking of a man who takes the Universe - if there is one - for granted. " -- http://mail.python.org/mailman/listinfo/python-list