From 5ecf5185f7cea9be134d3438aa21841d49637070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 11 Dec 2014 22:28:12 +0100 Subject: [PATCH] DictDescriptor must return a copy of the dictionary Dictionary are mutable so to prevent modification of the internal value of the Dict field, a copy of the value must be returned. issue4389 review5841002 --- proteus/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/proteus/__init__.py b/proteus/__init__.py index 872549fd5a..4501c3b49c 100644 --- a/proteus/__init__.py +++ b/proteus/__init__.py @@ -226,6 +226,12 @@ class TimeDescriptor(FieldDescriptor): class DictDescriptor(FieldDescriptor): + def __get__(self, instance, owner): + value = super(DictDescriptor, self).__get__(instance, owner) + if value: + value = value.copy() + return value + def __set__(self, instance, value): assert isinstance(value, dict) or value is None super(DictDescriptor, self).__set__(instance, value)