1
0
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:
Daniel Mach 2024-02-14 13:58:57 +01:00
parent aa6ccac69a
commit acc54919fc

View File

@ -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