[Python-Dev] with_traceback
James Y Knight
foom at fuhm.net
Thu Mar 1 19:51:54 CET 2007
On Mar 1, 2007, at 3:27 AM, Greg Ewing wrote:
> James Y Knight wrote:
>> The traceback won't necessarily be *useful*,
>
> Almost completely use*less*, I would have thought.
> The traceback is mostly used to find out where
> something went wrong, not where it went right (i.e.
> successful creation of the exception).
The advantages are that it's an easily understandable and explainable
behavior, and the traceback points you (the programmer) to the exact
location where you went wrong: creating the exception at module level.
Creating an exception with a non-exceptional stacktrace isn't always
useless: sometimes you have exceptions where you know you never care
about the stacktrace (internal flow control/etc).
> This would be a major and surprising change to Python
> users.
It's only a major change if you don't raise the exception in the same
place you create it. (which other people are claiming is extremely
rare).
> It would also be considerably *more* expensive to implement
> than the current scheme, because it would require copying the
> entire stack, instead of just linking stack frames together
> as they are unwound during the search for an exception
> handler.
Yes of course, you're right, I withdraw the proposal. I had forgotten
that python doesn't currently save the entire stack, only that
between the 'raise' and the 'except'. (I had forgotten, because
Twisted's "Failure" objects do save and print the entire stacktrace,
both above and below the catch-point).
James
More information about the Python-Dev
mailing list