RFC: addCleanup should take *args and **kwargs?
Martin Pool
mbp at sourcefrog.net
Sat Apr 14 02:45:59 BST 2007
On 4/13/07, Aaron Bentley <aaron.bentley at utoronto.ca> wrote:
> > robert> On Fri, 2007-04-13 at 08:03 +0200, Vincent Ladeuil wrote:
> > >>
> > >> +1, as long as we take care of checking the presence of the
> > >> callable *and* its (*args, **kwargs)
> >
> > robert> What do you mean by this?
> >
> > addCleanup checks that callable is not already in the cleanup
> > list, if we use the same callable for different parameters, it
> > should still be added, not rejected as a dupe.
> >
> > Nit-picking, better safe than sorry, etc :)
>
> I don't think you can predict that
>
> 1. If a programmer mistakently adds a cleanup twice, that this fix will
> catch it
> 2. If a programmer adds a cleanup twice, it is a mistake.
>
> So I don't think this is a good idea. If double-adding a cleanup causes
> an error, the programmer will see this and fix it. If it is not an
> error, it should not be forbidden.
I think I added the prohibition of double-added cleanups, but I now
think it was a mistake and am +1 on removing it. As well as what
Aaron says, the point of addCleanup is to make the cleanup visible in
the code near where the resource is allocated and that in itself helps
avoid mistakes.
--
Martin
More information about the bazaar
mailing list