Commit 96e1dc6d authored by Arnaud Fontaine's avatar Arnaud Fontaine

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.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43933 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f5f7f921
...@@ -250,12 +250,14 @@ class ListGetter(Base.Getter): ...@@ -250,12 +250,14 @@ class ListGetter(Base.Getter):
list_value = evaluateTales(instance=instance, value=list_value) list_value = evaluateTales(instance=instance, value=list_value)
else: else:
return list_value 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(list_value) # Make sure we return a list rather than a tuple
return list_value return list_value
if default is None: if default is None:
return None # nothing was defined as default so None is the appropriate value 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 list(default) # Make sure we return a list rather than a tuple
return default return default
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment