[Python-Dev] Product iteration

Fredrik Lundh Fredrik Lundh" <effbot@telia.com
Thu, 27 Jul 2000 09:32:42 +0200


moshe wrote:
> On Wed, 26 Jul 2000, Jeremy Hylton wrote:
>=20
> > The argument about finalization is specious.  You should not write
> > code that depends on current finalization semantics to do things =
like
> > closing files.  It's relying on an implementation-dependent feature
> > that is not part of the language spec.  (Just try it on JPython.)
>=20
> I know, and I'm not. But the thing is, there are plenty of users of
> CPython which do rely on this feature -- so you're going to break
> people's code. Not nice.

one problem is that there are many places when you don't know
if you can close the file or not -- whoever handed you the file handle
might expect it to remain open after you've done with it.

That's why people use stuff like:

    self.fp =3D None # close if I'm the last user

:::

But wouldn't

    fp =3D fopen(...);
    if (!fp && (errno =3D=3D EMFILE || errno =3D=3D ENFILE)) {
        py_force_gc();
        fp =3D fopen(...);
    }

solve this, at least for simple scripts?

</F>