PyErr_NormalizeException()

If a new exception occurs while an exception instance is being
created, try harder to make sure there is a traceback.  If the
original exception had a traceback associated with it and the new
exception does not, keep the old exception.

Of course, callers to PyErr_NormalizeException() must still be
prepared to have tb set to NULL.

XXX This isn't an ideal solution, but it's better than no traceback at
all.  It occurs if, for example, the exception occurs when the call to
the constructor fails before any Python code is executed.  Guido
suggests that it there is Python code that was about to be executed
-- but wasn't, say, because it was called with the wrong number of
arguments -- then we should point at the first line of the code object
anyway.
1 file changed