[Erp5-report] r43933 arnaud.fontaine - /erp5/trunk/products/ERP5Type/Accessor/List.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Mar 3 12:58:34 CET 2011
Author: arnaud.fontaine
Date: Thu Mar 3 12:58:34 2011
New Revision: 43933
URL: http://svn.erp5.org?rev=43933&view=rev
Log:
Getter class for List Accessors must return a copy if it is a list,
otherwise, as callers expect to be able to modify it, the list grows
at each call.
Modified:
erp5/trunk/products/ERP5Type/Accessor/List.py
Modified: erp5/trunk/products/ERP5Type/Accessor/List.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Accessor/List.py?rev=43933&r1=43932&r2=43933&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Accessor/List.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Accessor/List.py [utf8] Thu Mar 3 12:58:34 2011
@@ -250,12 +250,14 @@ class ListGetter(Base.Getter):
list_value = evaluateTales(instance=instance, value=list_value)
else:
return list_value
- if type(list_value) is TupleType:
+ # Even if it is already a list, return a copy as callers
+ # expect to be able to modify it on place
+ if isinstance(list_value, (list, tuple, set)):
return list(list_value) # Make sure we return a list rather than a tuple
return list_value
if default is None:
return None # nothing was defined as default so None is the appropriate value
- if type(default) is TupleType:
+ if isinstance(default, (list, tuple, set)):
return list(default) # Make sure we return a list rather than a tuple
return default
More information about the Erp5-report
mailing list