[Python-Dev] Traceback style
Guido van Rossum
guido@python.org
Tue, 02 May 2000 09:58:51 -0400
[Skip]
> On a not-quite unrelated tack, I wonder if traceback printing can be
> enhanced in the case where Python code calls a function or method written in
> C (possibly calling multiple C functions), which in turn calls a Python
> function that raises an exception. Currently, the Python functions on
> either side of the C functions are printed, but no hint of the C function's
> existence is displayed. Any way to get some indication there's another
> function in the middle?
In some cases, that's a good thing -- in others, it's not. There
should probably be an API that a C function can call to add an entry
onto the stack.
It's not going to be a trivial fix though -- you'd have to manufacture
a frame object.
I can see two options: you can do this "on the way out" when you catch
an exception, or you can do this "on the way in" when you are called.
The latter would require you to explicitly get rid of the frame too --
probably both on normal returns and on exception returns. That seems
hairier than only having to make a call on exception returns; but it
means that the C function is invisible to the Python debugger unless
it fails.
--Guido van Rossum (home page: http://www.python.org/~guido/)