Guido van Rossum wrote:
[Guido]
What if that method catches that exception?
[Ka-Ping Yee]
Did you mean something like this?
def handle():
try:
open('spamspamspam')
except:
catchit()
# point A
...
def catchit():
Suppose exceptions have an optional context attribute, which is
set when the exception is raised in the context of handling another
exception. Thus:
def a():
try:
raise AError
except:
raise BError
yields an exception which is an instance of BError.
Guido van Rossum wrote:
[Ka-Ping Yee]
Suppose exceptions have an optional context attribute, which is
set when the exception is raised in the context of handling another
exception. Thus:
def a():
try:
raise AError
except:
raise BError
yields an
[Brett C.]
If a new exception is raised (e.g., not a bare 'raise') while a current
exception is active (e.g., sys.exc_info() would return something other than a
tuple of None), then the new exception is made the active exception and the
now
old exception is assigned to the new exception's
On Thu, 12 May 2005, Guido van Rossum wrote:
Define raise. Does that involve a raise statement?
Not necessarily; it could be a raise statement or an inadvertently
triggered exception, such as in the example code i posted.
What about 1/0?
That counts.
What if you call a method that executes
[Phillip J. Eby]
I think the main problem is going to be that (IIUC), Python doesn't know
when you've exited an 'except:' clause and are therefore no longer
handling the exception.
But the compiler knows and could insert code to maintain this state.
sys.exc_info() still gives you the
[Guido]
What if that method catches that exception?
[Ka-Ping Yee]
Did you mean something like this?
def handle():
try:
open('spamspamspam')
except:
catchit()
# point A
...
def catchit():
try:
On May 12, 2005, at 6:32 PM, Ka-Ping Yee wrote:
Suppose exceptions have an optional context attribute, which is
set when the exception is raised in the context of handling another
exception. Thus:
def a():
try:
raise AError
except:
raise
James Y Knight wrote:
Of course you can already do similar with current python, it just
can't be spelled as nicely, and the default traceback printer won't
use the info:
try:
raise AError
except:
newException = BError()
newException.cause=sys.exc_info()
raise newException
[James Y Knight ]
I think it's a bad idea to have this happen automatically. Many times
if an exception is raised in the except clause, that doesn't
necessarily imply it's related to the original exception. It just
means there's a bug in the exception handler.
Yeah, but especially in that
10 matches
Mail list logo