mirror of
https://github.com/openSUSE/osc.git
synced 2024-12-29 11:16:14 +01:00
Fix BaseModel to always deepcopy mutable defaults on first use
This commit is contained in:
parent
aa6ccac69a
commit
acc54919fc
@ -257,6 +257,10 @@ class Field(property):
|
||||
|
||||
try:
|
||||
result = obj._defaults[self.name]
|
||||
if isinstance(result, (dict, list)):
|
||||
# make a deepcopy to avoid problems with mutable defaults
|
||||
result = copy.deepcopy(result)
|
||||
obj._values[self.name] = result
|
||||
if self.get_callback is not None:
|
||||
result = self.get_callback(obj, result)
|
||||
return result
|
||||
|
Loading…
Reference in New Issue
Block a user