[Zope-CMF] [dev] Re: shared mutable defaults

Yuppie schubbe@web.de
Thu, 06 Feb 2003 09:46:49 +0100


Tres Seaver wrote (regarding a cvs checkin for ActionProviderBase.py):
>>-    _actions = ()
>>+    _actions = []
> Past experience has demonstrated quite painfully that shared mutable
> defaults are evil, and a source of really hard-to-find bugs;  code which
> works fine in unit tests, and when only one user is working on a system,
> breaks mysteriously when multiple users / requests are firing.
> Nobody should depend on this, so please revert it (the next part is
> fine).  Any change you made which *does* depend on having the class
> attribute be a list is, by definition, a bug waiting to be discovered.

*All* subclasses of ActionProviderBase overwrite this default tuple with 
a default list. I thought there is a reason for that, but it seems I was 
wrong: '_actions' needs to be a sequence, not a list.

Does that mean all action providers are broken and should be fixed?