[Python-checkins] r54394 - in python/trunk: Lib/wave.py Misc/NEWS

Jim Jewett jimjjewett at gmail.com
Thu Mar 15 18:42:40 CET 2007


On 3/15/07, Georg Brandl <g.brandl at gmx.net> wrote:
> Raymond Hettinger schrieb:
> >> -        self.initfp(f)
> >> +        try:
> >> +            self.initfp(f)
> >> +        except:
> >> +            if self._i_opened_the_file:
> >> +                f.close()
> >> +            raise

> > Do you really want a bare except?
> > Would a try/finally approach work here?

> The file shouldn't be closed if there was no exception,
> but the except could probably be narrowed to wave.Error and EOFError.

Why should it be narrowed?  Wouldn't other (unexpected) exceptions
also bubble up and cause the same leak?

Is there really a general problem with bare except *when it includes a
bare raise*?

-jJ


More information about the Python-checkins mailing list