Message68576
On Sun, Jun 22, 2008 at 1:04 PM, Antoine Pitrou <report@bugs.python.org> wrote:
>
> Antoine Pitrou <pitrou@free.fr> added the comment:
>
> Le dimanche 22 juin 2008 à 17:17 +0000, Adam Olsen a écrit :
>> I meant only that trivial cycles should be detected. However, I
>> hadn't read your patch, so I didn't realize you already knew of a way
>> to create a non-trivial cycle.
>>
>> This has placed a niggling doubt in my mind about chaining the
>> exceptions, rather than the tracebacks. Hrm.
>
> Chaining the tracebacks rather than the exceptions loses important
> information: what is the nature of the exception which is the cause or
> context of the current exception?
I assumed each leg of the traceback would reference the relevant exception.
Although.. this is effectively the same as creating a new exception
instance when reraised, rather than modifying the old one. Reusing
the old is done for performance I believe.
> It is improbable to create such a cycle involuntarily, it means you
> raise an old exception in replacement of a newer one caused by the
> older, which I think is quite contorted. It is also quite easy to avoid
> creating the cycle, simply by re-raising outside of any except handler.
I'm not convinced.
try:
... # Lookup
except A as a: # Lookup failed
try:
... # Fallback
except B as b: # Fallback failed
raise a # The original exception is of the type we want
For this behaviour, this is the most natural way to write it.
Conceptually, there shouldn't be a cycle - the traceback should be the
lookup, then the fallback, then whatever code is about this - exactly
the order the code executed in. |
|
Date |
User |
Action |
Args |
2008-06-22 19:23:23 | Rhamphoryncus | set | spambayes_score: 0.00016397 -> 0.00016397012 recipients:
+ Rhamphoryncus, gvanrossum, pitrou, benjamin.peterson |
2008-06-22 19:23:22 | Rhamphoryncus | link | issue3112 messages |
2008-06-22 19:23:21 | Rhamphoryncus | create | |
|