[Python-Dev] exec/with thunk-handling proposal
Moore, Paul
Paul.Moore@atosorigin.com
Tue, 4 Feb 2003 16:03:09 -0000
From: Guido van Rossum [mailto:guido@python.org]
> > > This made me realize something. What happens if some sort of
> > > exception is raised between 'f1 =3D open()' and the start of the
> > > block 'with autoclose(f1):'?
> > [...]
> > > Please let me know what simple fact I'm missing.
> >=20
> > Nothing much, other than the fact that this is an issue with the
> > try...except form as well. Basically, this isn't a problem that
> > the proposal is trying to solve.
>
> Actually, I care about this race condition, and for certain situations
> I plan to solve it by implementing a bit of magic in C.
It would be nice if the "with" statement specification could define the
equivalent code and then say "but the with statement is immune to race
conditions involving exceptions arriving between the start of the
execution of the with expression, and the start of the implied try =
block".
The implementation of the with statement should copy whatever magic you
are going to use.
Paul.