Re: Destructors and exceptions
From: Christos (tzot_at_sil-tec.gr)
Date: 06/08/04
- Next message: Peter Hickman: "Re: Python Speed Question and Opinion"
- Previous message: fishboy: "Re: simple script to read and output Mailbox body to file."
- In reply to: David Turner: "Destructors and exceptions"
- Next in thread: Nick Jacobson: "Re: Destructors and exceptions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 08 Jun 2004 12:19:15 +0300
On 7 Jun 2004 07:51:23 -0700, rumours say that dkturner@telkomsa.net
(David Turner) might have written:
>Hi all
>
>I noticed something interesting while testing some RAII concepts
>ported from C++ in Python. I haven't managed to find any information
>about it on the web, hence this post.
>
>The problem is that when an exception is raised, the destruction of
>locals appears to be deferred to program exit. Am I missing
>something? Is this behaviour by design? If so, is there any reason
>for it? The only rationale I can think of is to speed up exception
>handling; but as this approach breaks many safe programming idioms, I
>see it as a poor trade.
[snip code]
ISTR that when an exception is raised, there is a reference to the code
frame (and therefore to its locals) kept somewhere; you can access this
info through the sys.exc_info call. Have you tried running
sys.exc_clear after the exception was raised?
Apart from that, advice from others not to rely on finalisation of
objects to clean up still applies.
-- TZOTZIOY, I speak England very best, "I have a cunning plan, m'lord" --Sean Bean as Odysseus/Ulysses
- Next message: Peter Hickman: "Re: Python Speed Question and Opinion"
- Previous message: fishboy: "Re: simple script to read and output Mailbox body to file."
- In reply to: David Turner: "Destructors and exceptions"
- Next in thread: Nick Jacobson: "Re: Destructors and exceptions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|