Exception question
Ron Adam
rrr at ronadam.com
Sun May 15 11:12:12 EDT 2005
Steven Bethard wrote:
> Ron Adam wrote:
>
>>Do exceptions that take place get stored in a stack or list someplace?
>
> [snip]
>
>>I know I can catch the error and store it myself with,
>>
>> except Exception, exc:
>>
>>or possibly,
>>
>> errlist = []
>> errlist.append(sys.exc_info())
>>
>>But what I want to know is does the interpreter do that in any way? And
>>if so, can I access it?
>
>
> No, but there's been some recent talk about having it do so:
>
> http://mail.python.org/pipermail/python-dev/2005-May/053672.html
>
> If that happens though, it's not likely to show up before Python 3.0.
> Too backwards incompatible to do now. It also seems that the exact
> semantics haven't yet been agreed upon.
>
> STeVe
Thanks Steve,
I had actually skimmed over those, but wasn't thinking of this at the
time. I reread them. And it clears up a few things.
I had read somewhere that exception objects were global, but that wasn't
correct, after testing it, they appear to be part of the local frame.
So once a function exits, any exceptions objects that happened inside
the function are no longer retrievable.
And checking exception ID's to see if any new exceptions occurred
doesn't work either, as the numbers get reused too frequently in a short
period.
Conclusion: Exceptions need to be logged or handled as they occur.
Cheers,
_Ron
More information about the Python-list
mailing list