RFC: addCleanup should take *args and **kwargs?

John Arbash Meinel john at arbash-meinel.com
Fri Apr 13 18:09:09 BST 2007


Aaron Bentley wrote:
> Vincent Ladeuil wrote:
>>>>>>> "robert" == Robert Collins <robertc at robertcollins.net> writes:
>>     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.
> 
> Aaron

I agree. I was just thinking about potentials for a "lock/unlock" combo.
Where one of the callers might be helpful by adding 'unlock()' for you.
But the test code adds another lock, so you need to add another unlock.

I would probably rather have addCleanup not check for duplicates.

John
=:->



More information about the bazaar mailing list